Prepared queries don't appear to be generated

I'm using Drizzle with Postgres.js, which should auto generate prepared queries. I have this query here
const prepared = db
.select({ response: customResponses.response })
.from(customResponses)
.where(eq(customResponses.trigger, sql.placeholder("trigger")))
.prepare("find_custom_response");
const prepared = db
.select({ response: customResponses.response })
.from(customResponses)
.where(eq(customResponses.trigger, sql.placeholder("trigger")))
.prepare("find_custom_response");
and have tested this query both with and without prepare. I've then (on the same application) run
await db
.select()
.from(sql`pg_prepared_statements`)
.execute();
await db
.select()
.from(sql`pg_prepared_statements`)
.execute();
to confirm that the prepared statement was created, but it always returns 0 rows, even after running the first query a bunch of times. I've also confirmed that the issue remains even after setting prepare: true in the Postgres.js config. Is there an issue here, or is my understanding of checking for prepared statements wrong?
1 Reply
fluxe
fluxeOP13mo ago
Just checked now as well, running db.execute(sql`SELECT * FROM pg_prepared_statements`) returns 1 entry, but for an unrelated pg_catalog.pg_type lookup. Nevermind, looking at postgres logs it does appear to be executing a prepared query, it's just not returned in the query (maybe because it's unamed? not sure)
Want results from more Discord servers?
Add your server