diff options
author | Tarmo Tänav <tarmo@itech.ee> | 2008-08-15 18:39:11 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-15 15:44:11 -0700 |
commit | e3523f1d33c3cf53f1a65e520be5e937e9c68c1d (patch) | |
tree | 4133486e17e4cafb88225bf86a8a1ee9efaf9730 | |
parent | aad7cac6add2fa01cebbb36e9f546292d632c9ea (diff) | |
download | rails-e3523f1d33c3cf53f1a65e520be5e937e9c68c1d.tar.gz rails-e3523f1d33c3cf53f1a65e520be5e937e9c68c1d.tar.bz2 rails-e3523f1d33c3cf53f1a65e520be5e937e9c68c1d.zip |
Fixed validates_uniqueness_of with decimal columns
Only use special case-sensitive comparison operators for text columns in
validates_uniqueness_of as mysql can fail at decimal comparisons with
the BINARY operator.
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index e7a9676394..b7e6394748 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -629,12 +629,11 @@ module ActiveRecord if value.nil? comparison_operator = "IS ?" - else + elsif is_text_column comparison_operator = "#{connection.case_sensitive_equality_operator} ?" - - if is_text_column - value = value.to_s - end + value = value.to_s + else + comparison_operator = "= ?" end sql_attribute = "#{record.class.quoted_table_name}.#{connection.quote_column_name(attr_name)}" |