Skip to content
This repository
Browse code

Fix uniqueness validator with `allow_nil: false` also for mysql

MySQL's adapter was changing value for case sensitive comparison. We
don't need to do it for `nil`.
  • Loading branch information...
commit 0d73d6e7b6dd1900f105397460b777ef6c03d3b6 1 parent f7d01ec
Piotr Sarnacki authored May 19, 2012
2  activerecord/lib/active_record/validations/uniqueness.rb
@@ -60,7 +60,7 @@ def build_relation(klass, table, attribute, value) #:nodoc:
60 60
           # will use SQL LOWER function before comparison, unless it detects a case insensitive collation
61 61
           relation = klass.connection.case_insensitive_comparison(table, attribute, column, value)
62 62
         else
63  
-          value    = klass.connection.case_sensitive_modifier(value)
  63
+          value    = klass.connection.case_sensitive_modifier(value) if value
64 64
           relation = table[attribute].eq(value)
65 65
         end
66 66
 

0 notes on commit 0d73d6e

Please sign in to comment.
Something went wrong with that request. Please try again.