diff options
author | pyromaniac <kinwizard@gmail.com> | 2011-07-28 19:09:12 +0400 |
---|---|---|
committer | pyromaniac <kinwizard@gmail.com> | 2012-01-06 18:31:34 +0700 |
commit | 5a4cdf9c918e6c80f1f254690499c9c3d7009604 (patch) | |
tree | bff48d59008d93d2a8b9a76beac3f3cec791a1c8 /activerecord/lib | |
parent | 432a95d88536696b65f0590b1624bd01fa88468f (diff) | |
download | rails-5a4cdf9c918e6c80f1f254690499c9c3d7009604.tar.gz rails-5a4cdf9c918e6c80f1f254690499c9c3d7009604.tar.bz2 rails-5a4cdf9c918e6c80f1f254690499c9c3d7009604.zip |
Fixed nil field value uniqueness check
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 8abe001775..55edb57206 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -52,13 +52,13 @@ module ActiveRecord def build_relation(klass, table, attribute, value) #:nodoc: column = klass.columns_hash[attribute.to_s] - value = column.limit ? value.to_s[0, column.limit] : value.to_s if column.text? + value = column.limit ? value.to_s[0, column.limit] : value.to_s if !value.nil? && column.text? if !options[:case_sensitive] && value && column.text? # will use SQL LOWER function before comparison, unless it detects a case insensitive collation relation = klass.connection.case_insensitive_comparison(table, attribute, column, value) else - value = klass.connection.case_sensitive_modifier(value) + value = klass.connection.case_sensitive_modifier(value) unless value.nil? relation = table[attribute].eq(value) end |