aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-04-11 10:02:39 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-11 10:02:39 -0700
commitc4fc3963003f53cb963435ea3733bd3e8164c803 (patch)
tree3201c98433c4d98806103acaa42abb571a087c2b
parent35b2715456999662cc34390e258962738aaa8dc7 (diff)
downloadrails-c4fc3963003f53cb963435ea3733bd3e8164c803.tar.gz
rails-c4fc3963003f53cb963435ea3733bd3e8164c803.tar.bz2
rails-c4fc3963003f53cb963435ea3733bd3e8164c803.zip
adding a case_sensitive_modifier for forcing comparisons to be case sensitive
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb5
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb5
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb1
4 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 0f44baa2fe..b0e6136e12 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -203,6 +203,10 @@ module ActiveRecord
def release_savepoint
end
+ def case_sensitive_modifier(node)
+ node
+ end
+
def current_savepoint_name
"active_record_#{open_transactions}"
end
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
index 7bad511c64..7e237db357 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -528,6 +528,11 @@ module ActiveRecord
def case_sensitive_equality_operator
"= BINARY"
end
+ deprecate :case_sensitive_equality_operator
+
+ def case_sensitive_modifier(node)
+ Arel::Nodes::Bin.new(node)
+ end
def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
where_sql
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index e1186209d3..ceee2ab73a 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -655,6 +655,11 @@ module ActiveRecord
def case_sensitive_equality_operator
"= BINARY"
end
+ deprecate :case_sensitive_equality_operator
+
+ def case_sensitive_modifier(node)
+ Arel::Nodes::Bin.new(node)
+ end
def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
where_sql
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index 37381d063d..d1225a9ed9 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -59,6 +59,7 @@ module ActiveRecord
if !options[:case_sensitive] && column.text?
relation = table[attribute].matches(value)
else
+ value = klass.connection.case_sensitive_modifier(value)
relation = table[attribute].eq(value)
end