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

Does not recognize expression indexes in Postgres #34

Open
adsteel opened this issue Jun 3, 2016 · 3 comments
Open

Does not recognize expression indexes in Postgres #34

adsteel opened this issue Jun 3, 2016 · 3 comments

Comments

@adsteel
Copy link

adsteel commented Jun 3, 2016

If you are using structure.sql in your Rails + Postgres project, you have the ability to use expression indexes. For example:

CREATE UNIQUE INDEX index_users_on_lower_name ON users(LOWER(name));

This can be mirrored in your ActiveRecord model:

class User
  validates :name, uniqueness: { case_insensitive: false }
end

With the above combination, the db constraint is consistent with the model, but this gem does not recognize it. The large number of expression indexes I have on my current project makes this gem difficult to use, though I understand that this practice is probably not too common in the Rails community.

@adsteel adsteel closed this as completed Jun 3, 2016
@adsteel adsteel reopened this Jun 3, 2016
@trptcolin
Copy link
Owner

Ah interesting, yeah this seems like a really useful feature - I'm surprised I haven't heard about it before!

This one and the other issue you opened look like they would be pretty hard to determine reliably and in full generality from a library's perspective. It makes me think maybe the right solution is to provide a way to tell consistency_fail to just ignore some specific "issues" that it detects. Maybe some input file of ignores, something like .gitignore...

But if anyone sees a nice way to actually implement the ideal solution (we correctly detect indexes like the above), then I'm all for that too, of course.

@kelvintyb
Copy link

@adsteel did u ever come up with a workaround for this? just ran into this issue myself.

@adsteel
Copy link
Author

adsteel commented Jul 2, 2019

@kelvintyb I did not.

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

3 participants