diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-14 09:19:49 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-14 09:32:37 +0900 |
commit | af653ef72190c6cd3e6b2a86786a981ad4bdb44e (patch) | |
tree | 697b61556c11f64322e2b3dfca1e3b739fec43ca /activerecord/test | |
parent | 7265b897805aee6b858fb72f5fc33e4622635dab (diff) | |
download | rails-af653ef72190c6cd3e6b2a86786a981ad4bdb44e.tar.gz rails-af653ef72190c6cd3e6b2a86786a981ad4bdb44e.tar.bz2 rails-af653ef72190c6cd3e6b2a86786a981ad4bdb44e.zip |
SQLite3: Support multiple args function for expression indexes
Follow up #33874.
Related #23393.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index 320f6efd56..7b73621ed9 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -348,34 +348,35 @@ module ActiveRecord if ActiveRecord::Base.connection.supports_expression_index? def test_expression_index with_example_table do - @conn.add_index "ex", "abs(number)", name: "expression" + @conn.add_index "ex", "max(id, number)", name: "expression" index = @conn.indexes("ex").find { |idx| idx.name == "expression" } - assert_equal %w{ abs(number) }, index.columns + assert_equal "max(id, number)", index.columns end end def test_expression_index_with_where with_example_table do - @conn.add_index "ex", "id % 10, abs(number)", name: "expression", where: "id > 1000" + @conn.add_index "ex", "id % 10, max(id, number)", name: "expression", where: "id > 1000" index = @conn.indexes("ex").find { |idx| idx.name == "expression" } - assert_equal ["id % 10", "abs(number)"], index.columns + assert_equal "id % 10, max(id, number)", index.columns assert_equal "id > 1000", index.where end end def test_complicated_expression with_example_table do - @conn.add_index "ex", "id % 10, (CASE WHEN number > 0 THEN abs(number) END)", name: "expression" + @conn.execute "CREATE INDEX expression ON ex (id % 10, (CASE WHEN number > 0 THEN max(id, number) END))WHERE(id > 1000)" index = @conn.indexes("ex").find { |idx| idx.name == "expression" } - assert_equal ["id % 10", "(CASE WHEN number > 0 THEN abs(number) END)"], index.columns + assert_equal "id % 10, (CASE WHEN number > 0 THEN max(id, number) END)", index.columns + assert_equal "(id > 1000)", index.where end end def test_not_everything_an_expression with_example_table do - @conn.add_index "ex", %w{ id abs(number) }, name: "expression" + @conn.add_index "ex", "id, max(id, number)", name: "expression" index = @conn.indexes("ex").find { |idx| idx.name == "expression" } - assert_equal %w{ id abs(number) }.sort, index.columns.sort + assert_equal "id, max(id, number)", index.columns end end end |