Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: #2272

Closed
sp88011 opened this issue May 7, 2024 · 1 comment
Closed

[BUG]: #2272

sp88011 opened this issue May 7, 2024 · 1 comment
Labels
bug Something isn't working priority Will be worked on next

Comments

@sp88011
Copy link

sp88011 commented May 7, 2024

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 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

@sp88011 sp88011 added the bug Something isn't working label May 7, 2024
@L-Mario564 L-Mario564 added the priority Will be worked on next label Oct 22, 2024
@AndriiSherman
Copy link
Member

was fixed in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority Will be worked on next
Projects
None yet
Development

No branches or pull requests

3 participants