classDelete
final class Delete
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A DELETE of the rows of a table that satisfy a predicate.
Rule: SQLITE-DELETE-001. The predicate sees the written table and, beyond it, the enclosing environment; the rest follows SQLITE-MUTATION-SCOPE-001. Source: https://sqlite.org/lang_delete.html. Status: Implemented.
$delete = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('DELETE FROM t WHERE a = 1 RETURNING a');
[$delete->statement->target->name->name->value, $delete->statement->where !== null, $delete->field(0)->name->value] // => ['t', true, 'a']Properties§
public list<ResultColumn|Star|TableStar> $returningpublic MutationTarget $targetpublic Scalar|null $where = nullpublic WithClause|null $with = nullMethods§
public function __construct(
public MutationTarget $target,
public Scalar|null $where = null,
list<ResultColumn|Star|TableStar> $returning = [],
public WithClause|null $with = null,
)Parameters
$target | MutationTarget | The written table |
$where | Scalar|null | The row predicate |
$returning | list<ResultColumn|Star|TableStar> | The RETURNING columns |
$with | WithClause|null | The WITH clause of the statement |
Throws
InvalidConstruction When a RETURNING column is of no result column classCalls 5
- method-call ClosedList::of() line 53
- new ClosedList line 53
- class-const ResultColumn::class() line 53
- class-const Star::class() line 53
- class-const TableStar::class() line 53
public function deriveStatement(Derivation $derivation): voidDerives the statement as a root and records the rows of RETURNING as the output.
Parameters
$derivation | Derivation |
Calls 5
- method-call ProgramOnly::outsideProgram() line 61
- new ProgramOnly line 61
- method-call Delete::deriveWithin() line 62
- method-call Derivation::environment() line 62
- method-call Derivation::output() line 64
public function deriveWithin(Derivation $derivation, Environment $outer): ?QueryFactDerives the statement inside an environment, as a trigger program does, and answers the rows it returns.
Parameters
$derivation | Derivation | |
$outer | Environment |
Returns
Called from 1
Calls 5
- new MutationScope line 73
- method-call MutationScope::open() line 74
- method-call Derivation::scalar() line 76
- new Environment line 76
- method-call MutationScope::returning() line 79
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 87
- method-call Output::keyword() line 89
Test cases 21§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 17
NameRuleTest::testPairPutsTheFirstNameAsTheSchemaOfTheSecondcallsLoweringTest::testStatementsLowersEveryCommandInOrderAndSkipsEmptyOnescallsMutationRuleTest::testCommandLowersEachDataChangeFormcallsMutationRuleTest::testDeleteLowersTheTargetThePredicateTheReturningAndTheWithClausecallsMutationRuleTest::testTargetLowersEveryFormOfTheWrittenTablecallsMutationRuleTest::testWhereReturningLowersEachOfTheFourTailscallsFromRuleTest::testOptionalIndexedIsNullWithoutAClausecallsQueryCommandsTest::testCommandPassesDataChangesToTheMutationRulescallsWithRuleTest::testOptionalIsNullWithoutAWithClauseOnADataChangecallsTriggerRuleTest::testProgramLowersEveryStatementInWrittenOrdercallsTriggerRuleTest::testStepLowersAnInsertWithItsUpsertAndADeleteWithItsPredicatecallsTriggerRuleTest::testTargetLowersTheWrittenTableWithItsIndexChoiceAndReportsWhatSqliteRefusescallsTriggerFactsTest::testDeriveReportsTriggerOnlyMisusesAndTheColumnsOfUpdateOfcallsMutationTargetTest::testDeriveRelationLeavesAnUndeclaredTargetOpencallsMutationTargetTest::testRenderWritesSchemaAliasAndIndexChoicecallsIndexChoiceTest::testRenderWritesNotIndexedWhenNoIndexIsNamedcallsCreateTriggerTest::testRejectsAStepWithAReturningClausecalls
Relations§
Instantiated in 2
Constant reads 1
Type checks 3
- instanceof SqlSemantics\Platform\Sqlite\Rules\Mutation\TriggerFacts::derive() packages/sql-semantics-sqlite/src/Rules/Mutation/TriggerFacts.php:71
- instanceof SqlSemantics\Platform\Sqlite\Rules\Mutation\TriggerFacts::derive() packages/sql-semantics-sqlite/src/Rules/Mutation/TriggerFacts.php:72
- instanceof SqlSemantics\Platform\Sqlite\Statement\Trigger\CreateTrigger::__construct() packages/sql-semantics-sqlite/src/Statement/Trigger/CreateTrigger.php:91