Skip to content

Commit 67991a4

Browse files
committed
feat: add returning to delete query
1 parent 82a46ec commit 67991a4

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/Query/Firebird/DeleteQuery.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,22 @@
77
use Latitude\QueryBuilder\ExpressionInterface;
88
use Latitude\QueryBuilder\Query;
99

10+
use Latitude\QueryBuilder\Query\Capability\HasReturning;
1011
use function is_int;
1112
use function Latitude\QueryBuilder\literal;
1213

1314
class 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)) {

tests/Query/Firebird/DeleteTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)