classMergeWhen
final class MergeWhen
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.One WHEN clause of MERGE: the rows it applies to, an optional condition and the action.
Mirrors PostgreSQL's MergeWhenClause. A clause for rows with a target row updates, deletes or skips; a clause for source rows without target row inserts or skips. 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 MATCHED AND u.c THEN DELETE');
$merge->statement->clauses[0]->condition !== null // => truenew \SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Merge\MergeWhen(\SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Merge\MergeMatch::Matched, null, new \SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Merge\MergeInsertDefaults()) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public MergeMatch $matchpublic Scalar|null $conditionpublic MergeUpdate|MergeDelete|MergeInsert|MergeInsertDefaults|MergeNothing $actionMethods§
public function __construct(
public MergeMatch $match,
public Scalar|null $condition,
public MergeUpdate|MergeDelete|MergeInsert|MergeInsertDefaults|MergeNothing $action,
)Parameters
$match | MergeMatch | The rows the clause applies to |
$condition | Scalar|null | The condition written after AND |
$action | MergeUpdate|MergeDelete|MergeInsert|MergeInsertDefaults|MergeNothing | The action |
Throws
InvalidConstruction When the action does not fit the rowsCalls 2
- static-call Check::input() line 47
- method-call MergeMatch::targeted() line 47
public function render(Output $out): voidWrites WHEN, the rows, the condition, THEN and the action.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 55
- class-const MergeMatch::Matched() line 56
- class-const MergeMatch::NotMatchedBySource() line 57
- class-const MergeMatch::NotMatched() line 58
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
MergeWhenTestcalls