File tree 3 files changed +17
-2
lines changed
3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function getConnection()
61
61
62
62
public function rowsIn (string $ table )
63
63
{
64
- $ this ->rowsInArray [$ table] ;
64
+ $ this ->rowsInArray [] = $ table ;
65
65
}
66
66
67
67
public function getRowsIn ()
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ protected function compileDelete(DeleteQuery $delete): string
152
152
$ query = 'DELETE FROM ' ;
153
153
$ rowsIn = $ delete ->getRowsIn ();
154
154
if (count ($ rowsIn ) > 0 ) {
155
- $ query = 'DELETE ' . join (', ' , $ rowsIn ) . ' FROM ' ;
155
+ $ query = 'DELETE ' . join (', ' , $ rowsIn ) . ' FROM ' ;
156
156
}
157
157
$ query .= $ this ->compileTable ($ delete ->getTable ());
158
158
foreach ($ delete ->getJoins () as $ join ) {
Original file line number Diff line number Diff line change @@ -24,4 +24,19 @@ public function testDeleteCase()
24
24
$ this ->assertEquals ('DELETE FROM table1 WHERE key = :v1 ' , $ compiled ->getQuery ());
25
25
$ this ->assertEquals (['v1 ' => 15 ], $ compiled ->getValues ());
26
26
}
27
+
28
+ public function testDeleteRowsIn ()
29
+ {
30
+ $ query = Query::deleteFrom (['t1 ' => 'table1 ' ]);
31
+ $ query ->innerJoin (['t2 ' => 'table2 ' ])
32
+ ->on ('t2.key1 ' , 't1.key1 ' );
33
+ $ query ->where ('t2.filter ' , 3 );
34
+ $ query ->rowsIn ('t1 ' );
35
+
36
+ $ compiled = $ this ->compiler ->compileQuery ($ query );
37
+
38
+ $ expected = 'DELETE t1 FROM table1 AS t1 INNER JOIN table2 AS t2 ON t2.key1 = t1.key1 WHERE t2.filter = :v1 ' ;
39
+ $ this ->assertEquals ($ expected , $ compiled ->getQuery ());
40
+ $ this ->assertEquals (['v1 ' => 3 ], $ compiled ->getValues ());
41
+ }
27
42
}
You can’t perform that action at this time.
0 commit comments