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

An INSERT of one row of column defaults: INSERT INTO table DEFAULT VALUES.

Mirrors PostgreSQL's InsertStmt without selectStmt. The facts follow PG-INSERT-001. Source: https://www.postgresql.org/docs/17/sql-insert.html. Status: Implemented.

Inserting the defaultsdoctest
$insert = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('insert into t default values returning *');
    $insert->toString() // => 'INSERT INTO t DEFAULT VALUES RETURNING *'

Properties§

public list<Target> $returning
public CommonTables|null $with
public TargetTable $target
public ConflictDoNothing|ConflictDoUpdate|null $conflict = null

Methods§

public function __construct(
    public CommonTables|null $with,
    public TargetTable $target,
    public ConflictDoNothing|ConflictDoUpdate|null $conflict = null,
    list<Target> $returning = [],
)

Parameters

$withCommonTables|nullThe WITH clause
$targetTargetTableThe table written; never with ONLY
$conflictConflictDoNothing|ConflictDoUpdate|nullThe ON CONFLICT clause
$returninglist<Target>The RETURNING list in written order

Throws

InvalidConstruction When the table is written with ONLY, or RETURNING holds a foreign item
Calls 3
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 2§

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 1

Relations§

Instantiated in 1
Type declarations 2