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

INSERT or REPLACE of one row written as SET assignments, with the optional row alias and ON DUPLICATE KEY UPDATE.

Rule: MYSQL-INSERT-SET-001. The facts follow MYSQL-INSERT-001; the assigned columns are the written columns and must be distinct. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html. Status: Implemented.

Reading the assignments of an INSERT ... SETdoctest
$insert = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('INSERT INTO t SET a = 1, b = a + 1');
    [count($insert->statement->assignments), $insert->toString()] // => [2, 'INSERT INTO t SET a = 1, b = a + 1']

Properties§

public list<Assignment> $assignments
public list<Assignment> $onDuplicate
public InsertInto $into
public RowAlias|null $alias = null

Methods§

public function __construct(
    public InsertInto $into,
    list<Assignment> $assignments,
    public RowAlias|null $alias = null,
    list<Assignment> $onDuplicate = [],
)

Parameters

$intoInsertIntoThe head: verb, modifiers and table; no column list
$assignmentslist<Assignment>The assignments of the row; at least one
$aliasRowAlias|nullThe alias of the new row
$onDuplicatelist<Assignment>The assignments of ON DUPLICATE KEY UPDATE

Throws

InvalidConstruction When the head has a column list, there is no assignment, or REPLACE has an alias or ON DUPLICATE KEY UPDATE
Calls 3
public function deriveStatement(Derivation $derivation): void

Derives the written table, the assignments and the assignments of ON DUPLICATE KEY UPDATE; the statement returns no rows.

Parameters

$derivationDerivation
Calls 3
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 2

Test cases 2§

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 1

Relations§

Instantiated in 2
Type declarations 1