File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77use Latitude \QueryBuilder \ExpressionInterface ;
88use Latitude \QueryBuilder \Query ;
99
10+ use Latitude \QueryBuilder \Query \Capability \HasReturning ;
1011use function is_int ;
1112use function Latitude \QueryBuilder \literal ;
1213
1314class DeleteQuery extends Query \DeleteQuery
1415{
16+ use HasReturning;
17+
18+ public function asExpression (): ExpressionInterface
19+ {
20+ $ query = parent ::asExpression ();
21+ $ query = $ this ->applyReturning ($ query );
22+
23+ return $ query ;
24+ }
25+
1526 protected function applyLimit (ExpressionInterface $ query ): ExpressionInterface
1627 {
1728 if (!is_int ($ this ->limit )) {
Original file line number Diff line number Diff line change @@ -19,4 +19,15 @@ public function testLimit(): void
1919 $ this ->assertSql ('DELETE FROM "users" ROWS 10 ' , $ delete );
2020 $ this ->assertParams ([], $ delete );
2121 }
22+
23+ public function testLimitWithReturning (): void
24+ {
25+ $ delete = $ this ->factory
26+ ->delete ('users ' )
27+ ->limit (10 )
28+ ->returning ('id ' );
29+
30+ $ this ->assertSql ('DELETE FROM "users" ROWS 10 RETURNING "id" ' , $ delete );
31+ $ this ->assertParams ([], $ delete );
32+ }
2233}
You can’t perform that action at this time.
0 commit comments