public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Cast value to string in validates_uniqueness_of if the column is of text type

This fixes an error for postgresql where "text_column = 100" fails in version 
8.3

Signed-off-by: Michael Koziarski <michael@koziarski.com>
Tarmo Tänav (author)
Thu Jul 31 09:26:18 -0700 2008
NZKoz (committer)
Thu Jul 31 11:28:39 -0700 2008
commit  68b207b087588fc9a2cc8edb842408e3be5ba9ef
tree    7a89e0c92251c3889e281e3a4b6ef5f9e16dccec
parent  896a3b9ab8dc02639ffa0b1dbf85011e1f3eda9b
...
625
626
627
628
 
 
 
 
 
 
 
629
630
631
...
625
626
627
 
628
629
630
631
632
633
634
635
636
637
0
@@ -625,7 +625,13 @@ module ActiveRecord
0
           # class (which has a database table to query from).
0
           finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? }
0
 
0
-          if value.nil? || (configuration[:case_sensitive] || !finder_class.columns_hash[attr_name.to_s].text?)
0
+          is_text_column = finder_class.columns_hash[attr_name.to_s].text?
0
+
0
+          if !value.nil? && is_text_column
0
+            value = value.to_s
0
+          end
0
+
0
+          if value.nil? || (configuration[:case_sensitive] || !is_text_column)
0
             condition_sql = "#{record.class.quoted_table_name}.#{attr_name} #{attribute_condition(value)}"
0
             condition_params = [value]
0
           else

Comments