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

Fix uniqueness validation to correctly work with expression indexes #49483

Merged

Conversation

fatkodima
Copy link
Member

Fixes #49481.

For expression indexes, IndexDefinition#columns is returned as a string and thats why we get an error.

@eileencodes eileencodes merged commit fafb6de into rails:main Oct 4, 2023
3 checks passed
eileencodes added a commit that referenced this pull request Oct 4, 2023
…-indexes

Fix uniqueness validation to correctly work with expression indexes
@eileencodes
Copy link
Member

Thanks for the quick fix. I backported to 7-1-stable in bfc686f

@fatkodima fatkodima deleted the fix-uniq-validation-for-expr-indexes branch October 4, 2023 08:38
yahonda added a commit to yahonda/rails that referenced this pull request Oct 4, 2023
This test can be run against these bundled adapters
if they `supports_expression_index?` returns `true`

SQL statement to create unique index for generated column.
- `sqlite3` adapter
CREATE UNIQUE INDEX "topics_index" ON "topics" ((LOWER(title)))

- `mysql2` and `trilogy` adapter
CREATE UNIQUE INDEX `topics_index` ON `topics` ((LOWER(title)))

- `postgresql` adapter
CREATE UNIQUE INDEX "topics_index" ON "topics" ((LOWER(title)))

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

Successfully merging this pull request may close these issues.

Rails 7.1.0rc2 NoMethodError: undefined method `-' in active_record/validations/uniqueness.rb:90
2 participants