diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-02-21 11:28:11 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-02-22 10:03:03 +0900 |
commit | b8f86ae29fde93b5f1e3ab75e57e4acb48a12b78 (patch) | |
tree | a7c253fa76f6b7cdb88c5b28244d6ebd28dc8612 /activerecord/test | |
parent | fa344194a8063bda06678868e0c2327b418c75cf (diff) | |
download | rails-b8f86ae29fde93b5f1e3ab75e57e4acb48a12b78.tar.gz rails-b8f86ae29fde93b5f1e3ab75e57e4acb48a12b78.tar.bz2 rails-b8f86ae29fde93b5f1e3ab75e57e4acb48a12b78.zip |
The BINARY Operator is only needed for string columns
Follow up to #13040.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/case_sensitivity_test.rb | 9 | ||||
-rw-r--r-- | activerecord/test/schema/mysql2_specific_schema.rb | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/case_sensitivity_test.rb b/activerecord/test/cases/adapters/mysql2/case_sensitivity_test.rb index 963116f08a..9cb05119a2 100644 --- a/activerecord/test/cases/adapters/mysql2/case_sensitivity_test.rb +++ b/activerecord/test/cases/adapters/mysql2/case_sensitivity_test.rb @@ -51,4 +51,13 @@ class Mysql2CaseSensitivityTest < ActiveRecord::Mysql2TestCase cs_uniqueness_query = queries.detect { |q| q.match(/string_cs_column/) } assert_no_match(/binary/i, cs_uniqueness_query) end + + def test_case_sensitive_comparison_for_binary_column + CollationTest.validates_uniqueness_of(:binary_column, case_sensitive: true) + CollationTest.create!(binary_column: 'A') + invalid = CollationTest.new(binary_column: 'A') + queries = assert_sql { invalid.save } + bin_uniqueness_query = queries.detect { |q| q.match(/binary_column/) } + assert_no_match(/\bBINARY\b/, bin_uniqueness_query) + end end diff --git a/activerecord/test/schema/mysql2_specific_schema.rb b/activerecord/test/schema/mysql2_specific_schema.rb index 101e657982..5a49b38457 100644 --- a/activerecord/test/schema/mysql2_specific_schema.rb +++ b/activerecord/test/schema/mysql2_specific_schema.rb @@ -33,6 +33,7 @@ ActiveRecord::Schema.define do create_table :collation_tests, id: false, force: true do |t| t.string :string_cs_column, limit: 1, collation: 'utf8_bin' t.string :string_ci_column, limit: 1, collation: 'utf8_general_ci' + t.binary :binary_column, limit: 1 end ActiveRecord::Base.connection.execute <<-SQL |