classUpsert
final class Upsert
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.One ON CONFLICT clause of an INSERT: what to do when a row violates a uniqueness constraint.
A clause without assignments is DO NOTHING; a clause with assignments is DO UPDATE SET, optionally restricted by a predicate. Source: https://sqlite.org/lang_upsert.html.
$insert = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('INSERT INTO t VALUES (1) ON CONFLICT (a) DO UPDATE SET a = excluded.a WHERE a < 5');
[count($insert->statement->upserts[0]->assignments), $insert->statement->upserts[0]->where !== null] // => [1, true]new \SqlSemantics\Platform\Sqlite\Statement\Mutation\Upsert(null, [], new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\NullLiteral()) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public list<Assignment|RowAssignment> $assignmentspublic ConflictTarget|null $target = nullpublic Scalar|null $where = nullMethods§
public function __construct(
public ConflictTarget|null $target = null,
list<Assignment|RowAssignment> $assignments = [],
public Scalar|null $where = null,
)Parameters
$target | ConflictTarget|null | The constraint the clause reacts to; null for any constraint |
$assignments | list<Assignment|RowAssignment> | The assignments of DO UPDATE; none for DO NOTHING |
$where | Scalar|null | The predicate of DO UPDATE |
Throws
InvalidConstruction When an assignment is of no assignment classCalls 5
- method-call ClosedList::of() line 46
- new ClosedList line 46
- class-const Assignment::class() line 46
- class-const RowAssignment::class() line 46
- static-call Check::input() line 47
public function render(Output $out): voidTest cases 5§
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 4
Relations§
Instantiated in 4
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\UpsertRule::tail() packages/sql-semantics-sqlite/src/Lowering/Mutation/UpsertRule.php:57
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\UpsertRule::tail() packages/sql-semantics-sqlite/src/Lowering/Mutation/UpsertRule.php:61
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\UpsertRule::tail() packages/sql-semantics-sqlite/src/Lowering/Mutation/UpsertRule.php:65
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\UpsertRule::tail() packages/sql-semantics-sqlite/src/Lowering/Mutation/UpsertRule.php:69
Constant reads 2
- class-const SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertRows::__construct() packages/sql-semantics-sqlite/src/Statement/Mutation/InsertRows.php:58
- class-const SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertSelect::__construct() packages/sql-semantics-sqlite/src/Statement/Mutation/InsertSelect.php:64