aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations/uniqueness.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-01 09:44:37 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-01 09:44:37 -0700
commitcab75da939399e80ee20faf15419f3ae30f2d28e (patch)
tree4adc9b8b86c657cfd7e07a50c52163b36b628596 /activerecord/lib/active_record/validations/uniqueness.rb
parent3fd78fc569077b3b844fea2cfc0e3115fef4c2ac (diff)
downloadrails-cab75da939399e80ee20faf15419f3ae30f2d28e.tar.gz
rails-cab75da939399e80ee20faf15419f3ae30f2d28e.tar.bz2
rails-cab75da939399e80ee20faf15419f3ae30f2d28e.zip
Don't rely on the column for type information in uniquness validations
The validator has access to richer type information
Diffstat (limited to 'activerecord/lib/active_record/validations/uniqueness.rb')
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb3
1 files changed, 2 insertions, 1 deletions
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