final class Update
    implements Statement, Selection
    uses Snapshot
Public API: explicitly declared with @visibility public.

An UPDATE of columns of the rows of a table that satisfy a predicate, optionally joined to further input.

Rule: SQLITE-UPDATE-001. The assigned values and the predicate see the written table and the relations of the FROM clause, which are derived by SQLITE-FROM-SCOPE-001; an assigned generated column is reported (SQLITE-GENERATED-WRITE-001); the rest follows SQLITE-MUTATION-SCOPE-001. Source: https://sqlite.org/lang_update.html. Status: Implemented.

Reading the parts of an UPDATEdoctest
$update = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('UPDATE OR FAIL t SET a = u.b FROM u WHERE t.id = u.id');
    [$update->statement->resolution, count($update->statement->assignments), $update->statement->from->name->name->value] // => [\SqlSemantics\Platform\Sqlite\Statement\Mutation\ConflictResolution::Fail, 1, 'u']
Refusing an UPDATE that assigns nothingdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Mutation\Update(new \SqlSemantics\Platform\Sqlite\Statement\Mutation\MutationTarget(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('t'))), []) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public non-empty-list<Assignment|RowAssignment> $assignments
public list<ResultColumn|Star|TableStar> $returning
public MutationTarget $target
public Relation|null $from = null
public Scalar|null $where = null
public ConflictResolution|null $resolution = null
public WithClause|null $with = null

Methods§

public function __construct(
    public MutationTarget $target,
    list<Assignment|RowAssignment> $assignments,
    public Relation|null $from = null,
    public Scalar|null $where = null,
    list<ResultColumn|Star|TableStar> $returning = [],
    public ConflictResolution|null $resolution = null,
    public WithClause|null $with = null,
)

Parameters

$targetMutationTargetThe written table
$assignmentslist<Assignment|RowAssignment>The assignments in written order; at least one
$fromRelation|nullThe further input relation
$whereScalar|nullThe row predicate
$returninglist<ResultColumn|Star|TableStar>The RETURNING columns
$resolutionConflictResolution|nullThe algorithm written after UPDATE OR
$withWithClause|nullThe WITH clause of the statement

Throws

InvalidConstruction When an assignment or a RETURNING column is of no admitted class
Calls 7
public function input(): ?Relation

Answers the further input relation of the FROM clause.

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 5
public function deriveWithin(Derivation $derivation, Environment $outer): ?QueryFact
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 2

Test cases 27§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4
Other tests reaching this symbol 23

Relations§

Instantiated in 2
Constant reads 1
Type checks 3
Type declarations 2