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
Add NULLS NOT DISTINCT
#6054
base: master
Are you sure you want to change the base?
Add NULLS NOT DISTINCT
#6054
Conversation
Thank you for the PR, please throw an error for other dialects when they try to use it |
Done! @rluvaton is it look well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for the other dialects that they are throwing and integration test for postgres that it actually works
({ indexName, deferrable, predicate } = indexName); | ||
({ indexName, deferrable, predicate, nullsNotDistinct } = indexName); | ||
} | ||
if (nullsNotDistinct !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow null as well
if (nullsNotDistinct !== undefined) { | |
if (nullsNotDistinct != null) { |
({ indexName, deferrable } = indexName); | ||
({ indexName, deferrable, nullsNotDistinct } = indexName); | ||
} | ||
if (nullsNotDistinct !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow null as well
if (nullsNotDistinct !== undefined) { | |
if (nullsNotDistinct != null) { |
} | ||
if (deferrable && deferrable !== 'not deferrable') { | ||
this.client.logger.warn( | ||
`mysql: unique index \`${indexName}\` will not be deferrable ${deferrable} because mysql does not support deferred constraints.` | ||
); | ||
} | ||
if (nullsNotDistinct !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow null as well
if (nullsNotDistinct !== undefined) { | |
if (nullsNotDistinct != null) { |
@@ -298,6 +300,9 @@ class TableCompiler_MSSQL extends TableCompiler { | |||
if (useConstraint && predicate) { | |||
throw new Error('mssql cannot create constraint with predicate'); | |||
} | |||
if (nullsNotDistinct !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow null as well
if (nullsNotDistinct !== undefined) { | |
if (nullsNotDistinct != null) { |
Postgres 15+ allows to add
NULLS NOT DISTINCT
for unique indexes and constraints.I added
nullNotDistinct: boolean
option forunique
inTableBuilder
, to make possible to use this feature.https://www.postgresql.org/about/featurematrix/detail/392/