From cab75da939399e80ee20faf15419f3ae30f2d28e Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 1 Jan 2015 09:44:37 -0700 Subject: Don't rely on the column for type information in uniquness validations The validator has access to richer type information --- activerecord/lib/active_record/validations/uniqueness.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 9ff2ad9c6b..f52f91e89c 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -59,7 +59,8 @@ module ActiveRecord end column = klass.columns_hash[attribute_name] - value = klass.connection.type_cast(value, column) + value = klass.type_for_attribute(attribute_name).type_cast_for_database(value) + value = klass.connection.type_cast(value) if value.is_a?(String) && column.limit value = value.to_s[0, column.limit] end -- cgit v1.2.3