You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a query I am trying to modify with a dynamic query (....$dynamic()) contains any placeholders, I'm getting an error that says No value for placeholder.... provided.
Is this a limitation of Drizzle, or am I thinking the wrong way about this?
Interestingly, the query seems to still work despite throwing an error.
Simple example to illustrate:
function withPagination<T extends PgSelect>(
qb: T,
page: number = 1,
pageSize: number = 10,
) {
return qb.limit(pageSize).offset((page - 1) * pageSize);
}
const query = db.select().from(users).where(eq(users.id, sql.placeholder("myPlaceholder"))
const dynamicQuery = query.$dynamic()
withPagination(dynamicQuery, 2, 20) // Error: No value for placeholder "myPlaceholder" was provided
Error: No value for placeholder "myPlaceholder" was provided
at eval (webpack-internal:///(rsc)/./node_modules/drizzle-orm/sql/sql.js:358:15)
at Array.map (<anonymous>)
at fillPlaceholders (webpack-internal:///(rsc)/./node_modules/drizzle-orm/sql/sql.js:355:17)
at eval (webpack-internal:///(rsc)/./node_modules/drizzle-orm/postgres-js/session.js:34:83)
at Object.startActiveSpan (webpack-internal:///(rsc)/./node_modules/drizzle-orm/tracing.js:14:14)
at PostgresJsPreparedQuery.execute (webpack-internal:///(rsc)/./node_modules/drizzle-orm/postgres-js/session.js:33:60)
at eval (webpack-internal:///(rsc)/./node_modules/drizzle-orm/pg-core/query-builders/select.js:713:30)
at Object.startActiveSpan (webpack-internal:///(rsc)/./node_modules/drizzle-orm/tracing.js:14:14)
at PgSelectBase.execute (webpack-internal:///(rsc)/./node_modules/drizzle-orm/pg-core/query-builders/select.js:712:60)
at PgSelectBase.then (webpack-internal:///(rsc)/./node_modules/drizzle-orm/query-promise.js:26:17)
at process.processTicksAndRejections..
Expected behavior
I should only be required to provide placeholder values when I actually execute the query, not when I'm still "building" it.
Environment & setup
Next.js, Supabase
The text was updated successfully, but these errors were encountered:
What version of
drizzle-orm
are you using?0.30.7
What version of
drizzle-kit
are you using?0.20.14
Describe the Bug
If a query I am trying to modify with a dynamic query (
....$dynamic()
) contains any placeholders, I'm getting an error that saysNo value for placeholder.... provided.
Is this a limitation of Drizzle, or am I thinking the wrong way about this?
Interestingly, the query seems to still work despite throwing an error.
Simple example to illustrate:
Expected behavior
I should only be required to provide placeholder values when I actually execute the query, not when I'm still "building" it.
Environment & setup
Next.js, Supabase
The text was updated successfully, but these errors were encountered: