Skip to content

Commit 134a189

Browse files
committed
Add high precision creation upsert regression test
This test ensures we use the same high precision timestamp for bulk record creation as we do for bulk record updates. See rails#42993 for details.
1 parent 16456ea commit 134a189

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

activerecord/test/cases/insert_all_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,14 @@ def test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_times
442442
end
443443
end
444444

445+
def test_upsert_all_respects_created_at_precision_when_touched_implicitly
446+
skip unless supports_datetime_with_precision?
447+
448+
Book.upsert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 8) }]
449+
450+
assert_not_predicate Book.find(101).created_at.usec, :zero?, "created_at should have sub-second precision"
451+
end
452+
445453
def test_upsert_all_implicitly_sets_timestamps_on_update_when_model_record_timestamps_is_true
446454
skip unless supports_insert_on_duplicate_update?
447455

0 commit comments

Comments
 (0)