1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't rely on the column for type information in uniquness validations

The validator has access to richer type information
This commit is contained in:
Sean Griffin 2015-01-01 09:44:37 -07:00
parent 3fd78fc569
commit cab75da939

View file

@ -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