classMutationRule
final class MutationRule
Lowers INSERT, UPDATE and DELETE.
Rule: SQLITE-MUTATION-LOWER-001. Scope: the cmd productions of DELETE, UPDATE and INSERT; insert_cmd, xfullname, setlist, where_opt_ret, returning. An INSERT whose source is a bare VALUES clause is an insert of written rows, any other source an insert of a query, DEFAULT VALUES an insert of defaults. Assignments keep their written order and whether the column is written as a parenthesised list. Terminates: the assignment list is walked along its spine in a loop. Source: https://sqlite.org/lang_insert.html, https://sqlite.org/lang_update.html, https://sqlite.org/lang_delete.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Calls 1
- new UpsertRule line 54
Lowers a data change command, or answers null for another command.
Parameters
$form | Form |
Returns
Calls 7
- method-call MutationRule::delete() line 65
- method-call Form::node() line 65
- method-call MutationRule::target() line 65
- method-call MutationRule::update() line 66
- method-call MutationRule::insert() line 67
- method-call MutationRule::into() line 67
- method-call MutationRule::defaults() line 68
public function delete(?WithClause $with, MutationTarget $target, Node $tail): DeleteLowers a DELETE from its parts.
Parameters
$with | ?WithClause | |
$target | MutationTarget | |
$tail | Node |
Returns
Called from 1
Calls 2
- method-call MutationRule::whereReturning() line 78
- new Delete line 80
Lowers an UPDATE command.
Parameters
$form | Form |
Returns
Called from 1
Calls 5
- method-call Form::node() line 89
- method-call MutationRule::target() line 91
- method-call MutationRule::assignments() line 92
- method-call MutationRule::whereReturning() line 94
- new Update line 96
public function into(
Node $verb,
MutationTarget $target,
Node $columns,
?WithClause $with,
): InsertIntoLowers the head of an INSERT.
Parameters
$verb | Node | |
$target | MutationTarget | |
$columns | Node | |
$with | ?WithClause |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 2
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::command() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:67
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::defaults() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:133
Calls 2
- new InsertInto line 110
- static-call ImplementationGap::production() line 112
public function insert(InsertInto $into, Node $select, Node $upsert): InsertRows|InsertSelectLowers an INSERT with a source query and its upsert tail.
Parameters
$into | InsertInto | |
$select | Node | |
$upsert | Node |
Returns
Called from 1
Calls 3
- method-call UpsertRule::tail() line 122
- new InsertRows line 124
- new InsertSelect line 124
public function defaults(Form $form): InsertDefaultsLowers an INSERT of default values.
Parameters
$form | Form |
Returns
Called from 1
Calls 5
- method-call Form::node() line 132
- method-call MutationRule::into() line 133
- method-call MutationRule::target() line 133
- new InsertDefaults line 135
- method-call MutationRule::returning() line 135
public function target(Node $name, ?IndexChoice $index = null): MutationTargetLowers an xfullname: the written table with its optional correlation name.
Parameters
$name | Node | |
$index | ?IndexChoice |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 4
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::command() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:65
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::command() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:67
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::update() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:91
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::defaults() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:133
Calls 3
- new MutationTarget line 149
- new QualifiedName line 149
- static-call ImplementationGap::production() line 153
public function assignments(Node $list): list<Assignment|RowAssignment>Lowers a setlist into its assignments in written order.
Parameters
$list | Node |
Returns
list<Assignment|RowAssignment>Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 6
- static-call ImplementationGap::production() line 172
- function-call
array_reverseline 176 - function-call
countline 177 - function-call
str_ends_withline 178 - new RowAssignment line 180
- new Assignment line 183
public function whereReturning(Node $tail): array{Scalar|null, list<ResultColumn|Star|TableStar>}Lowers a where_opt_ret into the predicate and the RETURNING columns.
Parameters
$tail | Node |
Returns
array{Scalar|null, list<ResultColumn|Star|TableStar>}Throws
ImplementationGap When the production has no ruleCalled from 2
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::delete() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:78
- method-call SqlSemantics\Platform\Sqlite\Lowering\Mutation\MutationRule::update() packages/sql-semantics-sqlite/src/Lowering/Mutation/MutationRule.php:94
Calls 1
- static-call ImplementationGap::production() line 207
public function returning(Node $returning): list<ResultColumn|Star|TableStar>Lowers a returning: the RETURNING columns, or none when the clause is absent.
Parameters
$returning | Node |
Returns
list<ResultColumn|Star|TableStar>Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 1
- static-call ImplementationGap::production() line 224
Private surface 2§
Implementation details, listed for orientation only.
private UpsertRule $upsertsprivate Lowering $loweringTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
MutationRuleTestcalls