diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-12-26 16:21:20 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-12-26 16:21:38 -0700 |
commit | efe5986696960c53deca53312cc6d67c0a303537 (patch) | |
tree | 3bb4d468f17fdf06141b63dbcf19309679834e77 /activerecord | |
parent | 09369726346e44ccb6cbe9d020094e734669f957 (diff) | |
download | rails-efe5986696960c53deca53312cc6d67c0a303537.tar.gz rails-efe5986696960c53deca53312cc6d67c0a303537.tar.bz2 rails-efe5986696960c53deca53312cc6d67c0a303537.zip |
We don't need to cast the value a second time in uniqueness validations
Part of the larger refactoring to remove type casting from Arel. Since
we've already cast the value a few lines above, we don't need to re-cast
it later. We can inform Arel of this by wrapping it in an
`Arel::Nodes::Quoted`, which will no longer be required in Rails 5.1
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 4dbe475331..255063e951 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -65,6 +65,7 @@ module ActiveRecord value = value.to_s[0, column.limit] end + value = Arel::Nodes::Quoted.new(value) if !options[:case_sensitive] && value && column.text? # will use SQL LOWER function before comparison, unless it detects a case insensitive collation klass.connection.case_insensitive_comparison(table, attribute, column, value) |