diff options
author | Tarmo Tänav <tarmo@itech.ee> | 2008-07-31 19:26:18 +0300 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-07-31 20:28:39 +0200 |
commit | 68b207b087588fc9a2cc8edb842408e3be5ba9ef (patch) | |
tree | 7a89e0c92251c3889e281e3a4b6ef5f9e16dccec /activerecord | |
parent | 896a3b9ab8dc02639ffa0b1dbf85011e1f3eda9b (diff) | |
download | rails-68b207b087588fc9a2cc8edb842408e3be5ba9ef.tar.gz rails-68b207b087588fc9a2cc8edb842408e3be5ba9ef.tar.bz2 rails-68b207b087588fc9a2cc8edb842408e3be5ba9ef.zip |
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>
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index b957ee3b9e..52f674847e 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -625,7 +625,13 @@ module ActiveRecord # class (which has a database table to query from). finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? } - if value.nil? || (configuration[:case_sensitive] || !finder_class.columns_hash[attr_name.to_s].text?) + is_text_column = finder_class.columns_hash[attr_name.to_s].text? + + if !value.nil? && is_text_column + value = value.to_s + end + + if value.nil? || (configuration[:case_sensitive] || !is_text_column) condition_sql = "#{record.class.quoted_table_name}.#{attr_name} #{attribute_condition(value)}" condition_params = [value] else |