classInsertRows
final class InsertRows
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.An INSERT of rows written in a VALUES clause.
Rule: SQLITE-INSERT-ROWS-001. The facts follow SQLITE-INSERT-001 with the VALUES clause as the source of the rows. Source: https://sqlite.org/lang_insert.html. Status: Implemented.
$insert = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze("INSERT INTO t (a, b) VALUES (1, 'x'), (2, 'y') RETURNING a");
[count($insert->statement->rows->rows), count($insert->statement->returning), $insert->toString()] // => [2, 1, "INSERT INTO t (a, b) VALUES (1, 'x'), (2, 'y') RETURNING a"]Properties§
public list<Upsert> $upsertspublic list<ResultColumn|Star|TableStar> $returningpublic InsertInto $intopublic ValuesClause $rowsMethods§
public function __construct(
public InsertInto $into,
public ValuesClause $rows,
list<Upsert> $upserts = [],
list<ResultColumn|Star|TableStar> $returning = [],
)Parameters
$into | InsertInto | The head: verb, written table and column list |
$rows | ValuesClause | The rows |
$upserts | list<Upsert> | The ON CONFLICT clauses; only the last may omit its conflict target |
$returning | list<ResultColumn|Star|TableStar> | The RETURNING columns |
Throws
InvalidConstruction When a RETURNING column is of no result column classCalls 9
- static-call Check::listOf() line 58
- class-const Upsert::class() line 58
- static-call Check::input() line 60
- function-call
countline 60 - method-call ClosedList::of() line 62
- new ClosedList line 62
- class-const ResultColumn::class() line 62
- class-const Star::class() line 62
- class-const TableStar::class() line 62
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 70
- new ProgramOnly line 70
- method-call InsertRows::deriveWithin() line 71
- method-call Derivation::environment() line 71
- method-call Derivation::output() line 73
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 2
- method-call InsertFacts::derive() line 82
- new InsertFacts line 82
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 90
- method-call Output::keyword() line 95
Test cases 29§
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 25
ConflictRuleTest::testOrConflictLowersTheAlgorithmAfterOrAndNullWithoutTheClausecallsConflictRuleTest::testResolutionLowersEachOfTheFiveAlgorithmscallsNameRuleTest::testListLowersTheNamesOfAnIdlistInWrittenOrdercallsNameRuleTest::testOptionalListGivesNoColumnsWithoutParenthesescallsMutationRuleTest::testCommandLowersEachDataChangeFormcallsMutationRuleTest::testInsertLowersWrittenRowsAndEveryOtherSourceAsAQuerycallsMutationRuleTest::testIntoLowersAnInsertWithItsOrClauseAndAReplacecallsUpsertRuleTest::testTailKeepsATargetedClauseBeforeTheUntargetedLastOnecallsUpsertRuleTest::testTailLowersAnEmptyTailAndAReturningOnlyTailcallsUpsertRuleTest::testTailLowersTargetedDoUpdateAndDoNothingClausesInWrittenOrdercallsUpsertRuleTest::testTailLowersTheUntargetedClausesThatEndTheTailWithTheirReturningcallsQueryCommandsTest::testCommandPassesDataChangesToTheMutationRulescallsTriggerRuleTest::testProgramLowersEveryStatementInWrittenOrdercallsTriggerRuleTest::testStepLowersAnInsertWithItsUpsertAndADeleteWithItsPredicatecallsGeneratedWritesTest::testRowidTargetRecognisesASingleNameOfTheRowidcallsGeneratedWritesTest::testSuppliedTellsWhetherTheInsertedRowSuppliesTheRowidcallsInsertFactsTest::testDeriveCountsTheSourceColumnsAgainstTheTargetcallsInsertFactsTest::testDeriveSkipsTheCountWhenEitherSideIsOpencallsConflictResolutionTest::testCasesAreReadAfterOrInInsertAndUpdatecallsConflictTargetTest::testRenderWritesTheTermsAndThePredicatecallsConflictTargetTest::testTermsAndPredicateSeeTheTargetTableOnlycallsInsertIntoTest::testRenderWritesTheVerbTheResolutionTheTargetAndTheColumnscallsUpsertTest::testAssignmentsAndPredicateSeeTheTableAndExcludedcallsUpsertTest::testRenderWritesDoNothingOrDoUpdateWithItsPredicatecallsCreateTriggerTest::testRejectsAnInsertWithACorrelationNamecalls
Relations§
Instantiated in 1
Constant reads 1
Type checks 2
- instanceof SqlSemantics\Platform\Sqlite\Rules\Mutation\TriggerFacts::derive() packages/sql-semantics-sqlite/src/Rules/Mutation/TriggerFacts.php:71
- instanceof SqlSemantics\Platform\Sqlite\Statement\Trigger\CreateTrigger::__construct() packages/sql-semantics-sqlite/src/Statement/Trigger/CreateTrigger.php:89