classMutationTarget
final class MutationTarget
implements NamedRelation
uses Snapshot
Public API: explicitly declared with
@visibility public.The table a data change statement writes to, with its optional correlation name and index choice.
Rule: SQLITE-MUTATION-TARGET-001. The name denotes a declared relation found along the schema search path; a common table of that name is never the target. The shape follows SQLITE-TABLE-SHAPE-001. Source: https://sqlite.org/lang_insert.html, https://sqlite.org/lang_update.html, https://sqlite.org/lang_delete.html. Status: Implemented.
$semantics = new \SqlSemantics\Platform\Sqlite\Semantics();
$table = $semantics->analyze('CREATE TABLE t (a INTEGER)');
$delete = $semantics->analyze('DELETE FROM t AS x WHERE x.a = 1', [$table]);
[$delete->statement->target->alias()->value, $delete->facts->relation($delete->statement->target)->table->table === $table->declarations()[0]] // => ['x', true]Properties§
public QualifiedName $namepublic Name|null $alias = nullpublic IndexChoice|null $index = nullMethods§
public function __construct(
public QualifiedName $name,
public Name|null $alias = null,
public IndexChoice|null $index = null,
)Parameters
$name | QualifiedName | The table name |
$alias | Name|null | The correlation name |
$index | IndexChoice|null | The demanded index |
public function name(): QualifiedNameAnswers the table name.
Returns
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactResolves the name among the declared relations and derives the row shape of the table.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 3
- method-call TableShapes::fact() line 69
- new TableShapes line 69
- method-call Derivation::environment() line 69
public function render(Output $out): voidWrites the name, the correlation name and the index choice.
Parameters
$out | Output |
Calls 6
- method-call Output::name() line 78
- class-const NameUse::Qualifier() line 78
- class-const NameUse::Relation() line 80
- method-call Output::keyword() line 82
- class-const NameUse::Alias() line 82
- method-call Output::node() line 84
Test cases 20§
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 19
InsertFactsTest::testDeriveLetsUpsertsSeeTheTargetAndExcludedInTheRightPlacescallsMutationScopeTest::testAssignChecksTheColumnsAndTheWidthOfEachAssignmentcallsMutationScopeTest::testNamesReportsColumnsAClosedTargetCertainlyLackscallsMutationScopeTest::testReturningIsNullWithoutColumnsAndProjectsTheTargetOtherwisecallsTriggerFactsTest::testDeriveReportsTriggerOnlyMisusesAndTheColumnsOfUpdateOfcallsAssignmentTest::testRenderWritesTheColumnAnEqualsSignAndTheValuecallsDeleteTest::testRenderWritesWithTargetWhereAndReturningcallsInsertDefaultsTest::testRenderWritesDefaultValuesAndReturningcallsInsertIntoTest::testRejectsATargetWithAnIndexChoicecallsInsertIntoTest::testRejectsReplaceWithAConflictResolutioncallsInsertRowsTest::testRejectsANonLastUpsertWithoutAConflictTargetcallsInsertSelectTest::testRejectsABareValuesClausecallsInsertSelectTest::testRejectsANonLastUpsertWithoutAConflictTargetcallsRowAssignmentTest::testRenderWritesTheColumnListAndTheValuecallsUpdateTest::testRejectsAnUpdateWithoutAssignmentscallsIndexChoiceTest::testRenderWritesNotIndexedWhenNoIndexIsNamedcallsCreateTriggerTest::testRejectsAnInsertWithACorrelationNamecallsCreateTriggerTest::testRejectsAStepWithAReturningClausecallsCreateTriggerTest::testRejectsAStepWithAWithClausecalls
Relations§
Instantiated in 8
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::target() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:149
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::target() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:150
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::target() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:151
- new SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::target() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:152
- new SqlSemantics\Platform\Sqlite\Lowering\Trigger\TriggerRule::target() packages/sql-semantics-sqlite/src/Lowering/Trigger/TriggerRule.php:191
- new SqlSemantics\Platform\Sqlite\Lowering\Trigger\TriggerRule::target() packages/sql-semantics-sqlite/src/Lowering/Trigger/TriggerRule.php:196
- new SqlSemantics\Platform\Sqlite\Lowering\Trigger\TriggerRule::target() packages/sql-semantics-sqlite/src/Lowering/Trigger/TriggerRule.php:197
- new SqlSemantics\Platform\Sqlite\Lowering\Trigger\TriggerRule::target() packages/sql-semantics-sqlite/src/Lowering/Trigger/TriggerRule.php:198
Type declarations 8
- type SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:76
- type SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:104
- type SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:143
- type SqlSemantics\Platform\Sqlite\Lowering\Trigger\TriggerRule packages/sql-semantics-sqlite/src/Lowering/Trigger/TriggerRule.php:181
- type SqlSemantics\Platform\Sqlite\Rules\Mutation\MutationScope packages/sql-semantics-sqlite/src/Rules/Mutation/MutationScope.php:53
- type SqlSemantics\Platform\Sqlite\Statement\Mutation\Delete packages/sql-semantics-sqlite/src/Statement/Mutation/Delete.php:51
- type SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertInto packages/sql-semantics-sqlite/src/Statement/Mutation/InsertInto.php:46
- type SqlSemantics\Platform\Sqlite\Statement\Mutation\Update packages/sql-semantics-sqlite/src/Statement/Mutation/Update.php:68