-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use a custom validation method to validate the uniqueness of name #1009
base: master
Are you sure you want to change the base?
Conversation
6935055
to
370a55c
Compare
case_sensitive
option for uniqueness validators
Any idea if this would get noticed soon? |
1 similar comment
Any idea if this would get noticed soon? |
@FunnyHector , can you rebase this PR. It good to merge. |
b134753
to
44f2e90
Compare
Hi @seuros , I have rebased this change onto the latest master. There was some conflict with this line in #1013. Could you please have another look? Sorry for late response. Somehow I must have missed the ping. |
@FunnyHector Do you mind merging |
@alto the only issue left here is the non i18n error message. |
@seuros Yeah, the one in |
Hiya, sorry I haven't really worked on any project that used i18n :p, that often slips my mind. I'll try to make a fix to use i18n, and rebase this work. I'm a little busy this week but hopefully I can get it done by the end of this week. Will ping you when I'm done. |
The intention of this change is to address the the following deprecation seen on Rails 6: DEPRECATION WARNING: Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1. To continue case sensitive comparison on the :name attribute in ActsAsTaggableOn::Tag model, pass `case_sensitive: true` option explicitly to the uniqueness validator. Since there is the complexity of the config `ActsAsTaggableOn.strict_case_match`, we can't just explicitly set case_sensitive option as suggested in the deprecation warning. The tests are quite blargh to deal with since the test database has the collation set to case-insensitive and has an uniqueness index, which is not realistic. To deal with the tests, I used a similar approach as in cb8d6e6. In cases where case sensitivity matters, we alter the collation on `name` column, run the test, then alter the collation back.
44f2e90
to
ed70273
Compare
This is the first custom error message so a locale file is added. For any non-en locale, this error message will raise a translation missing error. Apps that uses this gem should add their own i18n translations.
d58a719
to
c9aeb0d
Compare
@seuros Hi, I just updated this pull request with your latest |
0d6d306
to
6dc9de1
Compare
Use a custom validation method to validate the uniqueness of name
The intention of this change is to address the the following deprecation seen on Rails 6:
Since there is the complexity of the config
ActsAsTaggableOn.strict_case_match
, we can't just explicitly set case_sensitive option as suggested in the deprecation warning.The tests are quite blargh to deal with since the test database has the collation set to case-insensitive and has an uniqueness index, which is not realistic. To deal with the tests, I used a similar approach as in cb8d6e6. In cases where case sensitivity matters, we alter the collation on
name
column, run the test, then alter the collation back.This PR tries to solve the same problem mentioned in #1005, but since the author of #1005 hasn't responded, I'm trying my luck here.
This change has also adopted @graaff's suggestion