classInsertDefaults
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.
$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> $returningpublic CommonTables|null $withpublic TargetTable $targetpublic ConflictDoNothing|ConflictDoUpdate|null $conflict = nullMethods§
public function __construct(
public CommonTables|null $with,
public TargetTable $target,
public ConflictDoNothing|ConflictDoUpdate|null $conflict = null,
list<Target> $returning = [],
)Parameters
$with | CommonTables|null | The WITH clause |
$target | TargetTable | The table written; never with ONLY |
$conflict | ConflictDoNothing|ConflictDoUpdate|null | The ON CONFLICT clause |
$returning | list<Target> | The RETURNING list in written order |
Throws
InvalidConstruction When the table is written with ONLY, or RETURNING holds a foreign itemCalls 3
- static-call Check::input() line 56
- static-call Check::listOf() line 57
- class-const Target::class() line 57
public function returnsRows(): boolTells whether the statement has a RETURNING list.
Returns
boolpublic function commonTables(): ?CommonTablesAnswers the WITH clause written before the statement.
Returns
public function deriveStatement(Derivation $derivation): voidDerives the statement as a root and records the rows of RETURNING as the output.
Parameters
$derivation | Derivation |
Calls 2
- method-call Roots::derive() line 81
- new Roots line 81
public function deriveQuery(Derivation $derivation, Environment $outer): QueryFactDerives every part against an outer environment and answers the rows of RETURNING.
Parameters
$derivation | Derivation | |
$outer | Environment |
Returns
Calls 2
- method-call InsertFacts::defaults() line 89
- new InsertFacts line 89
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 97
- method-call Output::keyword() line 99
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.