classRowAlias
final class RowAlias
implements Relation
uses Snapshot
@visibility public.The alias AS name [(column, ...)] of the new row of INSERT, which ON DUPLICATE KEY UPDATE refers to (MySQL 8.0.19 and later).
Rule: MYSQL-DML-ROW-ALIAS-001. The alias is a relation with one column per written column, in order, holding the value that row would insert; its columns take the names of the alias column list, or the names of the written columns. The statement derives the alias at a position whose environment holds the written columns as its fields, or, when the written table is not declared completely, that table as its relation: the columns then depend on the missing declaration. A column list of another length, or a repeated column name, is reported as the server does for derived column names. Terminates: no child. Source: https://dev.mysql.com/doc/refman/8.4/en/insert-on-duplicate.html. Status: Implemented.
$insert = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('INSERT INTO t (a, b) VALUES (1, 2) AS new (m, n) ON DUPLICATE KEY UPDATE a = m + n');
[$insert->statement->alias->name->value, count($insert->statement->alias->columns)] // => ['new', 2]Properties§
public list<Name> $columnspublic Name $nameMethods§
Calls 2
- static-call Check::listOf() line 59
- class-const Name::class() line 59
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives one column per written column, named by the column list when it is written.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 12
- function-call
array_pushline 69 - new OutputSlot line 74
- new Dependent line 74
- class-const Nullability::Dependent() line 74
- new RelationFact line 77
- new RowShape line 77
- function-call
countline 80 - method-call Derivation::report() line 81
- new CountMismatch line 81
- class-const CountedList::DerivedColumns() line 81
- new Misuse line 89
- class-const MisuseRule::DuplicateColumn() line 89
public function render(Output $out): voidWrites the alias and its column list.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 103
- class-const NameUse::Alias() line 103
- method-call Output::symbol() line 105
- method-call Output::name() line 110
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
RowAliasTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 1
Type declarations 5
- type SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:136
- type SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:192
- type SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:182
- type SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertRows packages/sql-semantics-mysql/src/Statement/Dml/Insert/InsertRows.php:49
- type SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertSet packages/sql-semantics-mysql/src/Statement/Dml/Insert/InsertSet.php:49