Skip to content

Case Insensitive Unique Indexes #47769

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

Closed
softwaregravy opened this issue Mar 25, 2023 · 2 comments
Closed

Case Insensitive Unique Indexes #47769

softwaregravy opened this issue Mar 25, 2023 · 2 comments

Comments

@softwaregravy
Copy link
Contributor

softwaregravy commented Mar 25, 2023

Unless this exists and I can't find it, this is a feature proposal/discussion.

I'm currently writing a migration and I'd like to end up with a case-insensitive unique index on a string column. The purpose is to mirror/enforce the following validation in the db:

validates :name, uniqueness: {case_sensitive: false}

Using postgres, it would look like this:

CREATE UNIQUE INDEX index_name ON table_name (UPPER(column_name));

UPPER or LOWER doesn't matter, it's used only in the index. Refer to Postgres docs

Putting this in a migration might look like this:

add_index :table, [:name], unique: true, case_sensitive: false

Probably ignore_case would only be valid if unique were true. Or we could use a unique_ignore_case

Thoughts on such a feature?

@rafaelfranca
Copy link
Member

Thank you so much for the issue but we don't take feature request on the issue tracker. We recommend you to try to implement the feature and send us a pull request or if you are in doubt if the feature will be accepts ask in the Rails Core discussion board for feedback.

@rafaelfranca rafaelfranca closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2023
@softwaregravy
Copy link
Contributor Author

@rafaelfranca Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants