-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Support NULLS NOT DISTINCT in Postgres 15+ #48608
Merged
rafaelfranca
merged 7 commits into
rails:main
from
grjones:postgres-index-nulls-not-distinct
Aug 3, 2023
Merged
Support NULLS NOT DISTINCT in Postgres 15+ #48608
rafaelfranca
merged 7 commits into
rails:main
from
grjones:postgres-index-nulls-not-distinct
Aug 3, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grjones
force-pushed
the
postgres-index-nulls-not-distinct
branch
from
June 29, 2023 05:56
38ef9e8
to
575a2e0
Compare
Buildkite failed for unrelated Trilogy tests but this looks to be a known issue: #48605 |
nvasilevski
reviewed
Jun 29, 2023
Co-authored-by: Nikita Vasilevsky <nvasilevskii@gmail.com>
grjones
force-pushed
the
postgres-index-nulls-not-distinct
branch
from
June 29, 2023 16:14
97505ec
to
8aa9b1b
Compare
@nvasilevski Let me know if there is anything more I can do. Many thanks. |
@grjones Thanks for taking this PR on! It's exactly what I need. Any updates available? |
davinlagerroos
pushed a commit
to umn-asr/oracle-enhanced
that referenced
this pull request
Feb 21, 2024
rails/rails#48608 adds an additional valid index option. Mirror that change here to allow the activerecord test schema to build
4 tasks
kamipo
added a commit
to kamipo/rails
that referenced
this pull request
Oct 26, 2024
rails#48608 implemented NULLS NOT DISTINCT for UNIQUE INDEX, but it also works for UNIQUE CONSTRAINT.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
PostgreSQL 15 introduced
NULLS NOT DISTINCT
in order to support unique indexes where you want to treat NULLs as equal. Otherwise, and by default, unique indexes allow any rows with null column values.This Pull Request has been created because creating unique indexes where rows can have only one null value is helpful, and it is a good idea to keep up with new PostgreSQL features.
Detail
This Pull Request changes the PostgreSQL connection adapter, schema detection, and schema generation. Prior work was done in #46659 but was incomplete--a DB created from schema.rb would not have
NULLS NOT DISTINCT
set. Additionally, #44803 addedINCLUDE
to the index schema regex, but this must come beforeNULLS [NOT] DISTINCT
per the Postgres docs.Additional information
Check out the PostreSQL docs here, in particular to confirm the correct ordering of SQL parts. My intent was to put it immediately after
INCLUDE
in regex detection and ruby argument order.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]