File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "cases/helper_sqlserver"
4
+ require "models/book"
5
+
6
+ class InsertAllTestSQLServer < ActiveRecord ::TestCase
7
+ # Test ported from the Rails `main` branch that is not on the `8-0-stable` branch.
8
+ def test_insert_all_only_applies_last_value_when_given_duplicate_identifiers
9
+ skip unless supports_insert_on_duplicate_skip?
10
+
11
+ Book . insert_all [
12
+ { id : 111 , name : "expected_new_name" } ,
13
+ { id : 111 , name : "unexpected_new_name" }
14
+ ]
15
+ assert_equal "expected_new_name" , Book . find ( 111 ) . name
16
+ end
17
+
18
+ # Test ported from the Rails `main` branch that is not on the `8-0-stable` branch.
19
+ def test_upsert_all_only_applies_last_value_when_given_duplicate_identifiers
20
+ skip unless supports_insert_on_duplicate_update? && !current_adapter? ( :PostgreSQLAdapter )
21
+
22
+ Book . create! ( id : 112 , name : "original_name" )
23
+
24
+ Book . upsert_all [
25
+ { id : 112 , name : "unexpected_new_name" } ,
26
+ { id : 112 , name : "expected_new_name" }
27
+ ]
28
+ assert_equal "expected_new_name" , Book . find ( 112 ) . name
29
+ end
30
+ end
You can’t perform that action at this time.
0 commit comments