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]: #2427

Open
mitchellwarr opened this issue Jun 3, 2024 · 0 comments
Open

[BUG]: #2427

mitchellwarr opened this issue Jun 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mitchellwarr
Copy link

What version of drizzle-orm are you using?

0.31.0

What version of drizzle-kit are you using?

0.22.1

Describe the Bug

Creating an index with a where condition

index('locations_open_orders_index')
      .on(table.locationId, table.startedAt.desc())
      .where(eq(table.open, true))

Creates in the migration file:

CREATE INDEX IF NOT EXISTS "locations_open_orders_index" ON "orders" USING btree (location_id,started_at DESC NULLS LAST) WHERE "orders"."open" = $1;--> statement-breakpoint

Which causes the migration to fail with:

applying migrations...error: there is no parameter $1

The docs say to use

// First example, with `.on()`
index('name')
  .on(table.column1.asc(), table.column2.nullsFirst(), ...) or .onOnly(table.column1.desc().nullsLast(), table.column2, ...)
  .concurrently()
  .where(sql``)
  .with({ fillfactor: '70' })

With the sql builder instead of the helper functions, and I'm about to use that instead, but there is no reason to suspect the helper functions wouldnt work here.

Expected behavior

In the migration file it would generate

CREATE INDEX IF NOT EXISTS "locations_open_orders_index" ON "orders" USING btree (location_id,started_at DESC NULLS LAST) WHERE "orders"."open" = true;

Environment & setup

No response

@mitchellwarr mitchellwarr added the bug Something isn't working label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant