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]: PG drizzle-kit introspect doesn't work for NOT DISTINCT('nulls') #4007

Open
1 task done
Mardoxx opened this issue Jan 26, 2025 · 2 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@Mardoxx
Copy link

Mardoxx commented Jan 26, 2025

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.30.2

What version of drizzle-kit are you using?

0.38.4

Other packages

No response

Describe the Bug

export const myTable = pgTable('my_table', {
  id: uuid('id').primaryKey(),
  field: text('email').unique(undefined, { nulls: 'not distinct' }),
});

Creates

ALTER TABLE "my_table" ADD CONSTRAINT "my_table_field_unique" UNIQUE NULLS NOT DISTINCT("field");

However

npx drizzle-kit introspect

Creates, wrongly;

CREATE TABLE "my_table" (
  "id" uuid PRIMARY KEY NOT NULL,
  "field" text,
  CONSTRAINT "my_table_field_unique" UNIQUE("field")
);
@Mardoxx Mardoxx added the bug Something isn't working label Jan 26, 2025
@Mardoxx Mardoxx changed the title [BUG]: PG drizzle-kit introspect doens't work for NOT DISTINCT('nulls') [BUG]: PG drizzle-kit introspect doesn't work for NOT DISTINCT('nulls') Jan 26, 2025
@Mardoxx Mardoxx changed the title [BUG]: PG drizzle-kit introspect doesn't work for NOT DISTINCT('nulls') [BUG]: PG drizzle-kit introspect doesn't work for NOT DISTINCT('nulls') Jan 26, 2025
@Mardoxx
Copy link
Author

Mardoxx commented Jan 26, 2025

The offending lines

uniqueConstrains[constraintName] = {
columns: [columnName],
nullsNotDistinct: false,
name: constraintName,
};

@Mardoxx
Copy link
Author

Mardoxx commented Jan 26, 2025

ftfy bussin

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