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)
745745 $ values = [$ values ];
746746 }
747747
748- $ values = $ this ->aliasIdForQuery ($ values );
748+ $ values = array_map (
749+ $ this ->aliasIdForQuery (...),
750+ $ values ,
751+ );
749752
750753 $ options = $ this ->inheritConnectionOptions ();
751754
Original file line number Diff line number Diff line change @@ -126,6 +126,22 @@ public function testInsert()
126126 $ this ->assertIsArray ($ user ->tags );
127127 }
128128
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+
129145 public function testInsertGetId ()
130146 {
131147 $ id = DB ::table ('users ' )->insertGetId (['name ' => 'John Doe ' ]);
You can’t perform that action at this time.
0 commit comments