aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations/uniqueness.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-07-06 16:04:14 -0600
committerSean Griffin <sean@thoughtbot.com>2014-07-06 16:04:14 -0600
commit3559230720d4ea52d290da4ff4734b5236220fcd (patch)
tree0f88c2f3a04ff278987abf0537daa5af1f3b18c7 /activerecord/lib/active_record/validations/uniqueness.rb
parent2f716694f20cd19464029513fb59440fd9000840 (diff)
downloadrails-3559230720d4ea52d290da4ff4734b5236220fcd.tar.gz
rails-3559230720d4ea52d290da4ff4734b5236220fcd.tar.bz2
rails-3559230720d4ea52d290da4ff4734b5236220fcd.zip
Remove the `text?` predicate from the type objects
This was only used for uniqueness validations. The first usage was in conjunction with `limit`. Types which cast to string, but are not considered text cannot have a limit. The second case was only with an explicit `:case_sensitive => true` option given by the user.
Diffstat (limited to 'activerecord/lib/active_record/validations/uniqueness.rb')
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index 04e28a0cfe..2a34969a8c 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -61,9 +61,11 @@ module ActiveRecord
column = klass.columns_hash[attribute_name]
value = klass.connection.type_cast(value, column)
- value = value.to_s[0, column.limit] if value && column.limit && column.text?
+ if value.is_a?(String) && column.limit
+ value = value.to_s[0, column.limit]
+ end
- if !options[:case_sensitive] && value && column.text?
+ if !options[:case_sensitive] && value.is_a?(String)
# will use SQL LOWER function before comparison, unless it detects a case insensitive collation
klass.connection.case_insensitive_comparison(table, attribute, column, value)
else