final class Delete
    implements Modification
    uses Snapshot
Public API: explicitly declared with @visibility public.

A DELETE: removal of the rows of a table that meet a condition, optionally joined with USING items.

Mirrors PostgreSQL's DeleteStmt (relation, usingClause, whereClause or CurrentOfExpr, returningList, withClause). The facts follow PG-CHANGE-001. Source: https://www.postgresql.org/docs/17/sql-delete.html. Status: Implemented.

Reading the parts of a DELETEdoctest
$delete = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('DELETE FROM ONLY t USING u WHERE t.a = u.a RETURNING *');
    [$delete->statement->target->table->only, $delete->toString()] // => [true, 'DELETE FROM ONLY t USING u WHERE t.a = u.a RETURNING *']

Properties§

public list<Target> $returning
public CommonTables|null $with
public TargetTable $target
public Relation|null $using = null
public Scalar|CurrentOf|null $where = null

Methods§

public function __construct(
    public CommonTables|null $with,
    public TargetTable $target,
    public Relation|null $using = null,
    public Scalar|CurrentOf|null $where = null,
    list<Target> $returning = [],
)

Parameters

$withCommonTables|nullThe WITH clause
$targetTargetTableThe table rows are deleted from
$usingRelation|nullThe USING item, or the list of USING items
$whereScalar|CurrentOf|nullThe condition, or the cursor position
$returninglist<Target>The RETURNING list in written order

Throws

InvalidConstruction When RETURNING holds a foreign item
Calls 2
public function returnsRows(): bool

Tells whether the statement has a RETURNING list.

Returns

bool
public function commonTables(): ?CommonTables

Answers the WITH clause written before the statement.

Returns

public function deriveStatement(Derivation $derivation): void

Derives the statement as a root and records the rows of RETURNING as the output.

Parameters

$derivationDerivation
Calls 2
public function deriveQuery(Derivation $derivation, Environment $outer): QueryFact

Derives every part against an outer environment and answers the rows of RETURNING.

Parameters

$derivationDerivation
$outerEnvironment

Returns

Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 2

Test cases 13§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 12

Relations§

Instantiated in 1
Type declarations 2