Skip to content

Commit

Permalink
Make sure all PostgreSQL tests pass when nulls not distinct isn't sup…
Browse files Browse the repository at this point in the history
…ported by the database
  • Loading branch information
rafaelfranca committed Aug 4, 2023
1 parent e6521dc commit 83e61ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -73,8 +73,10 @@ def test_add_index
expected = %(CREATE INDEX IF NOT EXISTS "index_people_on_last_name" ON "people" ("last_name"))
assert_equal expected, add_index(:people, :last_name, if_not_exists: true)

expected = %(CREATE INDEX "index_people_on_last_name" ON "people" ("last_name") NULLS NOT DISTINCT)
assert_equal expected, add_index(:people, :last_name, nulls_not_distinct: true)
if supports_nulls_not_distinct?
expected = %(CREATE INDEX "index_people_on_last_name" ON "people" ("last_name") NULLS NOT DISTINCT)
assert_equal expected, add_index(:people, :last_name, nulls_not_distinct: true)
end

assert_raise ArgumentError do
add_index(:people, :last_name, algorithm: :copy)
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/migration/index_test.rb
Expand Up @@ -301,11 +301,15 @@ def test_add_index_with_included_column_and_where_clause
end

def test_add_index_with_nulls_not_distinct_assert_exists_with_same_values
skip("current adapter doesn't support nulls not distinct") unless supports_nulls_not_distinct?

connection.add_index("testings", "last_name", nulls_not_distinct: true)
assert connection.index_exists?("testings", "last_name", nulls_not_distinct: true)
end

def test_add_index_with_nulls_not_distinct_assert_exists_with_different_values
skip("current adapter doesn't support nulls not distinct") unless supports_nulls_not_distinct?

connection.add_index("testings", "last_name", nulls_not_distinct: false)
assert_not connection.index_exists?("testings", "last_name", nulls_not_distinct: true)
end
Expand Down

0 comments on commit 83e61ca

Please sign in to comment.