Skip to content

Commit 448a7b0

Browse files
committed
Ensure query_constraints_list is empty if primary_key is nil
1 parent 51e9fa9 commit 448a7b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

activerecord/test/cases/persistence_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,15 @@ def test_primary_key_stays_the_same
14391439
assert_equal("id", ClothingItem.primary_key)
14401440
end
14411441

1442+
def test_query_constraints_list_is_an_empty_array_if_primary_key_is_nil
1443+
klass = Class.new(ActiveRecord::Base) do
1444+
self.table_name = "developers_projects"
1445+
end
1446+
1447+
assert_nil klass.primary_key
1448+
assert_empty klass.query_constraints_list
1449+
end
1450+
14421451
def test_query_constraints_uses_primary_key_by_default
14431452
post = posts(:welcome)
14441453
assert_uses_query_constraints_on_reload(post, "id")

0 commit comments

Comments
 (0)