classMergeInsert
final class MergeInsert
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.The action INSERT ... VALUES of a MERGE WHEN clause: one row is inserted from the source row.
Mirrors a MergeWhenClause with CMD_INSERT, its column list, override and values. A value may be DEFAULT. Source: https://www.postgresql.org/docs/17/sql-merge.html.
$merge = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('MERGE INTO t USING u ON t.a = u.a WHEN NOT MATCHED THEN INSERT (a) OVERRIDING USER VALUE VALUES (u.a)');
[count($merge->statement->clauses[0]->action->values), $merge->toString()] // => [1, 'MERGE INTO t USING u ON t.a = u.a WHEN NOT MATCHED THEN INSERT (a) OVERRIDING USER VALUE VALUES (u.a)']new \SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Merge\MergeInsert([], null, []) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public list<ColumnTarget> $columnspublic non-empty-list<Scalar> $valuespublic Overriding|null $overridingMethods§
public function __construct(
list<ColumnTarget> $columns,
public Overriding|null $overriding,
list<Scalar> $values,
)Parameters
$columns | list<ColumnTarget> | The column list in written order |
$overriding | Overriding|null | Whose values identity columns receive |
$values | list<Scalar> | The values in written order; at least one |
Throws
InvalidConstruction When there is no value, or a list holds a foreign itemCalls 3
- static-call Check::listOf() line 53
- class-const ColumnTarget::class() line 53
- class-const Scalar::class() line 54
public function render(Output $out): voidWrites INSERT, the columns, the override and VALUES.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 62
- method-call Output::symbol() line 64
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
MergeInsertTestcalls
Other tests reaching this symbol 2
Relations§
Instantiated in 4
- new SqlSemantics\Platform\PostgreSql\Lowering\Manipulation\MergeRule::action() packages/sql-semantics-postgres/src/Lowering/Manipulation/MergeRule.php:144
- new SqlSemantics\Platform\PostgreSql\Lowering\Manipulation\MergeRule::action() packages/sql-semantics-postgres/src/Lowering/Manipulation/MergeRule.php:145
- new SqlSemantics\Platform\PostgreSql\Lowering\Manipulation\MergeRule::action() packages/sql-semantics-postgres/src/Lowering/Manipulation/MergeRule.php:146
- new SqlSemantics\Platform\PostgreSql\Lowering\Manipulation\MergeRule::action() packages/sql-semantics-postgres/src/Lowering/Manipulation/MergeRule.php:147
Type checks 2
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::clause() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:94
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Merge\MergeWhen::__construct() packages/sql-semantics-postgres/src/Statement/Manipulation/Merge/MergeWhen.php:45
Type declarations 2
- type SqlSemantics\Platform\PostgreSql\Lowering\Manipulation\MergeRule packages/sql-semantics-postgres/src/Lowering/Manipulation/MergeRule.php:136
- type SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Merge\MergeWhen packages/sql-semantics-postgres/src/Statement/Manipulation/Merge/MergeWhen.php:43