@@ -64,6 +64,8 @@ def test_insert_all
64
64
end
65
65
66
66
def test_insert_all_should_handle_empty_arrays
67
+ skip unless supports_insert_on_duplicate_update?
68
+
67
69
assert_empty Book . insert_all ( [ ] )
68
70
assert_empty Book . insert_all! ( [ ] )
69
71
assert_empty Book . upsert_all ( [ ] )
@@ -277,25 +279,27 @@ def test_insert_all_logs_message_including_model_name
277
279
end
278
280
279
281
def test_insert_all_and_upsert_all_with_aliased_attributes
282
+ skip unless supports_insert_on_duplicate_update?
283
+
280
284
if supports_insert_returning?
281
285
assert_difference "Book.count" do
282
286
result = Book . insert_all [ { title : "Remote" , author_id : 1 } ] , returning : :title
283
287
assert_includes result . columns , "title"
284
288
end
285
289
end
286
290
287
- if supports_insert_on_duplicate_update?
288
- Book . upsert_all [ { id : 101 , title : "Perelandra" , author_id : 7 , isbn : "1974522598" } ]
289
- Book . upsert_all [ { id : 101 , title : "Perelandra 2" , author_id : 6 , isbn : "111111" } ] , update_only : %i[ title isbn ]
291
+ Book . upsert_all [ { id : 101 , title : "Perelandra" , author_id : 7 , isbn : "1974522598" } ]
292
+ Book . upsert_all [ { id : 101 , title : "Perelandra 2" , author_id : 6 , isbn : "111111" } ] , update_only : %i[ title isbn ]
290
293
291
- book = Book . find ( 101 )
292
- assert_equal "Perelandra 2" , book . title , "Should have updated the title"
293
- assert_equal "111111" , book . isbn , "Should have updated the isbn"
294
- assert_equal 7 , book . author_id , "Should not have updated the author_id"
295
- end
294
+ book = Book . find ( 101 )
295
+ assert_equal "Perelandra 2" , book . title , "Should have updated the title"
296
+ assert_equal "111111" , book . isbn , "Should have updated the isbn"
297
+ assert_equal 7 , book . author_id , "Should not have updated the author_id"
296
298
end
297
299
298
300
def test_insert_all_and_upsert_all_with_sti
301
+ skip unless supports_insert_on_duplicate_update?
302
+
299
303
assert_difference -> { Category . count } , 2 do
300
304
SpecialCategory . insert_all [ { name : "First" } , { name : "Second" , type : nil } ]
301
305
end
@@ -304,15 +308,13 @@ def test_insert_all_and_upsert_all_with_sti
304
308
assert_equal "SpecialCategory" , first . type
305
309
assert_nil second . type
306
310
307
- if supports_insert_on_duplicate_update?
308
- SpecialCategory . upsert_all [ { id : 103 , name : "First" } , { id : 104 , name : "Second" , type : nil } ]
311
+ SpecialCategory . upsert_all [ { id : 103 , name : "First" } , { id : 104 , name : "Second" , type : nil } ]
309
312
310
- category3 = Category . find ( 103 )
311
- assert_equal "SpecialCategory" , category3 . type
313
+ category3 = Category . find ( 103 )
314
+ assert_equal "SpecialCategory" , category3 . type
312
315
313
- category4 = Category . find ( 104 )
314
- assert_nil category4 . type
315
- end
316
+ category4 = Category . find ( 104 )
317
+ assert_nil category4 . type
316
318
end
317
319
318
320
def test_upsert_logs_message_including_model_name
0 commit comments