What exactly i am doing wrong.. Prepared Query

[{
"error": {
"json": {
"message": "prepared statement \"preparedConfig\" already exists",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "config.fetch",
"zodError": null
}
}
}
}]
[{
"error": {
"json": {
"message": "prepared statement \"preparedConfig\" already exists",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "config.fetch",
"zodError": null
}
}
}
}]
export const preparedConfig = db.query.config
.findFirst({
with: { ads: true, banners: true },
orderBy: [asc(config.config.id)],
})
.prepare("preparedConfig");

// Calling using trpc

fetch: publicProcedure.query(async ({ ctx }) => {
return await preparedConfig.execute();
}),
export const preparedConfig = db.query.config
.findFirst({
with: { ads: true, banners: true },
orderBy: [asc(config.config.id)],
})
.prepare("preparedConfig");

// Calling using trpc

fetch: publicProcedure.query(async ({ ctx }) => {
return await preparedConfig.execute();
}),
12 Replies
Andrii Sherman
Andrii Sherman16mo ago
Can you share a runtime you are using? Also the connection driver you are using and do you have this name only for this prepared statement or some other as well?
Yamato
YamatoOP16mo ago
do you have this name only for this prepared statement or some other as well?
This is my first prepared statement
No description
Andrii Sherman
Andrii Sherman16mo ago
Do you see this error on the first run or just on subsequent runs/requests?
Yamato
YamatoOP16mo ago
I think first time when i open the webpage it returned data but after that it's returning same error even tho i am hard reloading page now it's returning 500 error
Yamato
YamatoOP16mo ago
No description
Andrii Sherman
Andrii Sherman16mo ago
and you are running it on vercel?
Yamato
YamatoOP16mo ago
yes let me try locally same
Andrii Sherman
Andrii Sherman16mo ago
сс @bloberenober @alexblokh
Yamato
YamatoOP16mo ago
Okay i tried other driver
No description
Yamato
YamatoOP16mo ago
it's working now but performance is very poor
Yamato
YamatoOP16mo ago
No description
Yamato
YamatoOP16mo ago
PS: without prepare on @vercel/postgres locally i was getting 230ms
Want results from more Discord servers?
Add your server