classInsertInto
final class InsertInto
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.The head of an INSERT statement: the verb, the conflict resolution, the written table and the column list.
REPLACE is the short spelling of INSERT OR REPLACE; the model keeps which one is written. Source: https://sqlite.org/lang_insert.html, https://sqlite.org/lang_replace.html.
$insert = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('INSERT OR IGNORE INTO t (a, b) VALUES (1, 2)');
[$insert->statement->into->resolution, $insert->statement->into->target->name->name->value, count($insert->statement->into->columns)] // => [\SqlSemantics\Platform\Sqlite\Statement\Mutation\ConflictResolution::Ignore, 't', 2]new \SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertInto(new \SqlSemantics\Platform\Sqlite\Statement\Mutation\MutationTarget(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('t'))), [], true, \SqlSemantics\Platform\Sqlite\Statement\Mutation\ConflictResolution::Ignore) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public list<Name> $columnspublic MutationTarget $targetpublic bool $replace = falsepublic ConflictResolution|null $resolution = nullpublic WithClause|null $with = nullMethods§
public function __construct(
public MutationTarget $target,
list<Name> $columns = [],
public bool $replace = false,
public ConflictResolution|null $resolution = null,
public WithClause|null $with = null,
)Parameters
$target | MutationTarget | The written table |
$columns | list<Name> | The columns that receive values; none when the list is absent |
$replace | bool | Whether the verb is REPLACE |
$resolution | ConflictResolution|null | The algorithm written after INSERT OR |
$with | WithClause|null | The WITH clause of the statement |
Calls 3
- static-call Check::listOf() line 52
- class-const Name::class() line 52
- static-call Check::input() line 53
public function render(Output $out): voidWrites the head up to the column list.
Parameters
$out | Output |
Calls 5
- method-call Output::node() line 62
- method-call Output::keyword() line 64
- method-call Output::symbol() line 68
- method-call Output::name() line 73
- class-const NameUse::Column() line 73
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 6
InsertFactsTest::testDeriveLetsUpsertsSeeTheTargetAndExcludedInTheRightPlacescallsInsertDefaultsTest::testRenderWritesDefaultValuesAndReturningcallsInsertRowsTest::testRejectsANonLastUpsertWithoutAConflictTargetcallsInsertSelectTest::testRejectsABareValuesClausecallsInsertSelectTest::testRejectsANonLastUpsertWithoutAConflictTargetcallsCreateTriggerTest::testRejectsAnInsertWithACorrelationNamecalls
Relations§
Instantiated in 2
Type declarations 6
- 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:119
- type SqlSemantics\Platform\Sqlite\Rules\Mutation\InsertFacts packages/sql-semantics-sqlite/src/Rules/Mutation/InsertFacts.php:52
- type SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertDefaults packages/sql-semantics-sqlite/src/Statement/Mutation/InsertDefaults.php:47
- type SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertRows packages/sql-semantics-sqlite/src/Statement/Mutation/InsertRows.php:56
- type SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertSelect packages/sql-semantics-sqlite/src/Statement/Mutation/InsertSelect.php:61