diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-30 11:42:54 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-30 11:42:54 -0700 |
commit | b93b39eff6829ee05ffec1cc8c505f69cbb53fdc (patch) | |
tree | 5b37fc7c7d36cc6e0abc2530606ea3acad05362c /activerecord/lib/active_record/validations | |
parent | 155b1b7fe3a1d231fb98a6fb04a21f6eb190b98f (diff) | |
download | rails-b93b39eff6829ee05ffec1cc8c505f69cbb53fdc.tar.gz rails-b93b39eff6829ee05ffec1cc8c505f69cbb53fdc.tar.bz2 rails-b93b39eff6829ee05ffec1cc8c505f69cbb53fdc.zip |
Remove most type related predicates from `Column`
Remaining are `limit`, `precision`, `scale`, and `type` (the symbol
version). These will remain on the column, since they mirror the options
to the `column` method in the schema definition DSL
Diffstat (limited to 'activerecord/lib/active_record/validations')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index f52f91e89c..8f7a46f2c7 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.type_for_attribute(attribute_name).type_cast_for_database(value) + cast_type = klass.type_for_attribute(attribute_name) + value = cast_type.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] @@ -67,7 +68,7 @@ module ActiveRecord value = Arel::Nodes::Quoted.new(value) - comparison = if !options[:case_sensitive] && value && column.text? + comparison = if !options[:case_sensitive] && value && cast_type.text? # will use SQL LOWER function before comparison, unless it detects a case insensitive collation klass.connection.case_insensitive_comparison(table, attribute, column, value) else |