diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-25 15:33:05 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-25 15:33:05 -0700 |
commit | 933644519c1ea639440379d813876f1edc12ca59 (patch) | |
tree | 64a8c88175efc165661d57f0788f0d7d6e36d46e /activerecord/lib | |
parent | 242d24d385e8a566d15f80b720ab126bde634162 (diff) | |
parent | 070c9984a50a5d715a8d2cd3847ae4b603a10d19 (diff) | |
download | rails-933644519c1ea639440379d813876f1edc12ca59.tar.gz rails-933644519c1ea639440379d813876f1edc12ca59.tar.bz2 rails-933644519c1ea639440379d813876f1edc12ca59.zip |
Merged pull request #306 from rsim/case_insensitive_uniqueness_validation_fix.
Do not use SQL LIKE operator for case insensitive uniqueness validation
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index d1225a9ed9..4db4105389 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -56,8 +56,9 @@ module ActiveRecord column = klass.columns_hash[attribute.to_s] value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if column.text? - if !options[:case_sensitive] && column.text? - relation = table[attribute].matches(value) + if !options[:case_sensitive] && value && column.text? + # will use SQL LOWER function before comparison + relation = table[attribute].lower.eq(table.lower(value)) else value = klass.connection.case_sensitive_modifier(value) relation = table[attribute].eq(value) |