diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-28 00:38:15 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-28 00:38:15 -0300 |
commit | 8cc515006568600095e2b1e33a935ff029f24bdf (patch) | |
tree | 020595ce24ac7ddf83360797580a442bd70fa387 /activerecord/test/cases/adapters/sqlite3/collation_test.rb | |
parent | add9500eb8d373407bf379d5ab8d833a055a07cd (diff) | |
parent | 3932912a5965f020999064ebde07b541394f72d4 (diff) | |
download | rails-8cc515006568600095e2b1e33a935ff029f24bdf.tar.gz rails-8cc515006568600095e2b1e33a935ff029f24bdf.tar.bz2 rails-8cc515006568600095e2b1e33a935ff029f24bdf.zip |
Merge pull request #20041 from akshay-vishnoi/sqlite_collation
SQLite3: Add collation support for string and text columns
Diffstat (limited to 'activerecord/test/cases/adapters/sqlite3/collation_test.rb')
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/collation_test.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/collation_test.rb b/activerecord/test/cases/adapters/sqlite3/collation_test.rb new file mode 100644 index 0000000000..39e4620bc9 --- /dev/null +++ b/activerecord/test/cases/adapters/sqlite3/collation_test.rb @@ -0,0 +1,53 @@ +require "cases/helper" +require 'support/schema_dumping_helper' + +class SQLite3CollationTest < ActiveRecord::TestCase + include SchemaDumpingHelper + + def setup + @connection = ActiveRecord::Base.connection + @connection.create_table :collation_table_sqlite3, force: true do |t| + t.string :string_nocase, collation: 'NOCASE' + t.text :text_rtrim, collation: 'RTRIM' + end + end + + def teardown + @connection.drop_table :collation_table_sqlite3, if_exists: true + end + + test "string column with collation" do + column = @connection.columns(:collation_table_sqlite3).find { |c| c.name == 'string_nocase' } + assert_equal :string, column.type + assert_equal 'NOCASE', column.collation + end + + test "text column with collation" do + column = @connection.columns(:collation_table_sqlite3).find { |c| c.name == 'text_rtrim' } + assert_equal :text, column.type + assert_equal 'RTRIM', column.collation + end + + test "add column with collation" do + @connection.add_column :collation_table_sqlite3, :title, :string, collation: 'RTRIM' + + column = @connection.columns(:collation_table_sqlite3).find { |c| c.name == 'title' } + assert_equal :string, column.type + assert_equal 'RTRIM', column.collation + end + + test "change column with collation" do + @connection.add_column :collation_table_sqlite3, :description, :string + @connection.change_column :collation_table_sqlite3, :description, :text, collation: 'RTRIM' + + column = @connection.columns(:collation_table_sqlite3).find { |c| c.name == 'description' } + assert_equal :text, column.type + assert_equal 'RTRIM', column.collation + end + + test "schema dump includes collation" do + output = dump_table_schema("collation_table_sqlite3") + assert_match %r{t.string\s+"string_nocase",\s+collation: "NOCASE"$}, output + assert_match %r{t.text\s+"text_rtrim",\s+collation: "RTRIM"$}, output + end +end |