classWriteTarget
final class WriteTarget
implements NamedRelation
uses Snapshot
@visibility public.The one table INSERT, REPLACE, LOAD DATA or a single-table DELETE writes, with its correlation name and partition selection.
Rule: MYSQL-DML-TARGET-001. The name resolves like a table reference (MYSQL-TABLE-SHAPES-001); a common table is no table a statement can write, which the server reports as a non-updatable target. Partition names are not checked: the context holds no partitions. Terminates: no child relation. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html, https://dev.mysql.com/doc/refman/8.4/en/delete.html, https://dev.mysql.com/doc/refman/8.4/en/partitioning-selection.html. Status: Implemented.
$delete = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('DELETE FROM shop.t AS x PARTITION (p0) WHERE x.a = 1');
[$delete->statement->table->name()->schema?->value, $delete->statement->table->alias()?->value, count($delete->statement->table->partitions)] // => ['shop', 'x', 1]Properties§
public list<Name> $partitionspublic QualifiedName $namepublic Name|null $alias = nullpublic AliasMark $mark = AliasMark::AsMethods§
public function __construct(
public QualifiedName $name,
public Name|null $alias = null,
list<Name> $partitions = [],
public AliasMark $mark = AliasMark::As,
)Parameters
$name | QualifiedName | The table name with its optional database |
$alias | Name|null | The correlation name; only a single-table DELETE of MySQL 8.0 and later writes one |
$partitions | list<Name> | The selected partitions |
$mark | AliasMark | What is written before the alias |
Calls 4
- class-const AliasMark::As() line 54
- static-call Check::input() line 56
- static-call Check::listOf() line 58
- class-const Name::class() line 58
public function name(): QualifiedNameAnswers the table name.
Returns
Test cases 1
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactResolves the name and derives the row shape of the table.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 5
- method-call TableShapes::named() line 82
- new TableShapes line 82
- method-call Derivation::report() line 84
- new WriteMisuse line 84
- class-const WriteRule::CommonTableTarget() line 84
public function render(Output $out): voidWrites the name, the correlation name and the partitions.
Parameters
$out | Output |
Calls 7
- method-call Output::name() line 96
- class-const NameUse::Qualifier() line 96
- class-const NameUse::Relation() line 98
- method-call AliasMark::write() line 100
- class-const NameUse::Alias() line 101
- method-call Output::keyword() line 104
- method-call Output::symbol() line 107
Test cases 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 8
SourceRelationsTest::testMembersAnswersTheJoinedRelationscallsInsertIntoTest::testRenderRejectsACorrelationNamecallsInsertIntoTest::testRenderRejectsReplaceWithIgnorecallsInsertRowsTest::testRenderRejectsReplaceWithUpdatescallsInsertSetTest::testRenderRejectsAColumnListcallsLoadTableTest::testRenderRejectsACorrelationNamecallsMultipleDeleteTest::testRenderRejectsAnEmptyTargetListcallsUpdateTest::testRenderRejectsAnUpdateWithoutAssignmentcalls
Relations§
Instantiated in 5
- new SqlSemantics\Platform\MySql\Lowering\Dml\ChangeRule::delete() packages/sql-semantics-mysql/src/Lowering/Dml/ChangeRule.php:113
- new SqlSemantics\Platform\MySql\Lowering\Dml\ChangeRule::legacyDelete() packages/sql-semantics-mysql/src/Lowering/Dml/ChangeRule.php:147
- new SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:91
- new SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::target() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:166
- new SqlSemantics\Platform\MySql\Lowering\Dml\LoadRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/LoadRule.php:114
Type declarations 4
- type SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:150
- type SqlSemantics\Platform\MySql\Statement\Dml\Delete packages/sql-semantics-mysql/src/Statement/Dml/Delete.php:54
- type SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertInto packages/sql-semantics-mysql/src/Statement/Dml/Insert/InsertInto.php:44
- type SqlSemantics\Platform\MySql\Statement\Dml\Load\LoadTable packages/sql-semantics-mysql/src/Statement/Dml/Load/LoadTable.php:83