Add index existence tests for nulls_not_distinct

This commit is contained in:
Gregory Jones 2023-06-29 01:49:48 -04:00
parent 52eb5d9c56
commit 575a2e0ea7
2 changed files with 12 additions and 2 deletions

View File

@ -58,8 +58,8 @@ module ActiveRecord
(name.nil? || self.name == name.to_s) &&
(unique.nil? || self.unique == unique) &&
(valid.nil? || self.valid == valid) &&
(include.nil? || Array(self.include) == Array(include).map(&:to_s) &&
(nulls_not_distinct.nil? || self.nulls_not_distinct == nulls_not_distinct))
(include.nil? || Array(self.include) == Array(include).map(&:to_s)) &&
(nulls_not_distinct.nil? || self.nulls_not_distinct == nulls_not_distinct)
end
private

View File

@ -299,6 +299,16 @@ module ActiveRecord
connection.remove_index("testings", "last_name")
assert_not connection.index_exists?("testings", "last_name", include: :foo, where: "first_name = 'john doe'")
end
def test_add_index_with_nulls_not_distinct_assert_exists_with_same_values
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
connection.add_index("testings", "last_name", nulls_not_distinct: false)
assert_not connection.index_exists?("testings", "last_name", nulls_not_distinct: true)
end
end
private