aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-01-27 10:47:15 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-02-12 23:57:15 +0900
commit811a4fa8eb6ceea841e61e8ac05747ffb69595ae (patch)
tree6ada1cfcf71a644d731f9ba7b55b7c06d260ee26 /activerecord/lib
parentf7aa4c92a0a0dd609b6e07a5db256c417d0aa235 (diff)
downloadrails-811a4fa8eb6ceea841e61e8ac05747ffb69595ae.tar.gz
rails-811a4fa8eb6ceea841e61e8ac05747ffb69595ae.tar.bz2
rails-811a4fa8eb6ceea841e61e8ac05747ffb69595ae.zip
Avoid a string value truncation in uniqueness validation
In MySQL, PostgreSQL, Oracle and SQLServer, a value over the limit cannot be inserted or updated (See #23522). In SQLite3, a value is inserted or updated regardless of the limit. We should avoid a string value truncation in uniqueness validation.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb3
1 files changed, 0 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index f0aa4521b5..6343de5914 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -69,9 +69,6 @@ module ActiveRecord
cast_type = klass.type_for_attribute(attribute_name)
value = cast_type.serialize(value)
value = klass.connection.type_cast(value)
- if value.is_a?(String) && column.limit
- value = value.to_s[0, column.limit]
- end
comparison = if !options[:case_sensitive] && !value.nil?
# will use SQL LOWER function before comparison, unless it detects a case insensitive collation