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

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
This commit is contained in:
Sean Griffin 2014-12-26 16:21:20 -07:00
parent 0936972634
commit efe5986696

View file

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