Skip to content

Commit 9845cf4

Browse files
authored
Coerce FieldOrderedValuesTest tests for SQL Server NULL uniqueness (#1390)
1 parent edc072c commit 9845cf4

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

test/cases/coerced_tests.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,39 @@ def test_in_order_of_with_array_values_with_nil_coerced
24582458
Book.where(author_id: nil, name: nil).delete_all
24592459
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
24602460
end
2461+
2462+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
2463+
coerce_tests! :test_in_order_of_with_out_of_bound_integer_does_not_match_nulls
2464+
def test_in_order_of_with_out_of_bound_integer_does_not_match_nulls_coerced
2465+
Book.lease_connection.remove_index(:books, column: [:author_id, :name])
2466+
2467+
original_test_in_order_of_with_out_of_bound_integer_does_not_match_nulls
2468+
ensure
2469+
Book.where(author_id: nil, name: nil).delete_all
2470+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
2471+
end
2472+
2473+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
2474+
coerce_tests! :test_in_order_of_with_only_unrepresentable_values_does_not_build_empty_case
2475+
def test_in_order_of_with_only_unrepresentable_values_does_not_build_empty_case_coerced
2476+
Book.lease_connection.remove_index(:books, column: [:author_id, :name])
2477+
2478+
original_test_in_order_of_with_only_unrepresentable_values_does_not_build_empty_case
2479+
ensure
2480+
Book.where(author_id: nil, name: nil).delete_all
2481+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
2482+
end
2483+
2484+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
2485+
coerce_tests! :test_in_order_of_with_unknown_enum_key_does_not_match_nulls
2486+
def test_in_order_of_with_unknown_enum_key_does_not_match_nulls_coerced
2487+
Book.lease_connection.remove_index(:books, column: [:author_id, :name])
2488+
2489+
original_test_in_order_of_with_unknown_enum_key_does_not_match_nulls
2490+
ensure
2491+
Book.where(author_id: nil, name: nil).delete_all
2492+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
2493+
end
24612494
end
24622495

24632496
class QueryLogsTest < ActiveRecord::TestCase

0 commit comments

Comments
 (0)