File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -745,7 +745,10 @@ public function insert(array $values)
745
745
$ values = [$ values ];
746
746
}
747
747
748
- $ values = $ this ->aliasIdForQuery ($ values );
748
+ $ values = array_map (
749
+ $ this ->aliasIdForQuery (...),
750
+ $ values ,
751
+ );
749
752
750
753
$ options = $ this ->inheritConnectionOptions ();
751
754
Original file line number Diff line number Diff line change @@ -126,6 +126,22 @@ public function testInsert()
126
126
$ this ->assertIsArray ($ user ->tags );
127
127
}
128
128
129
+ #[TestWith([true ])]
130
+ #[TestWith([false ])]
131
+ public function testInsertWithCustomId (bool $ renameEmbeddedIdField )
132
+ {
133
+ $ connection = DB ::connection ('mongodb ' );
134
+ $ connection ->setRenameEmbeddedIdField ($ renameEmbeddedIdField );
135
+
136
+ $ data = ['id ' => 'abcdef ' , 'name ' => 'John Doe ' ];
137
+
138
+ DB ::table ('users ' )->insert ($ data );
139
+
140
+ $ user = User::find ('abcdef ' );
141
+ $ this ->assertInstanceOf (User::class, $ user );
142
+ $ this ->assertSame ('abcdef ' , $ user ->id );
143
+ }
144
+
129
145
public function testInsertGetId ()
130
146
{
131
147
$ id = DB ::table ('users ' )->insertGetId (['name ' => 'John Doe ' ]);
You can’t perform that action at this time.
0 commit comments