classDeferrability
final class Deferrability
implements ColumnConstraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A DEFERRABLE or NOT DEFERRABLE clause of a foreign key.
Rule: SQLITE-FK-DEFERRABLE-001. A foreign key is checked at the end of the transaction only when the clause is DEFERRABLE INITIALLY DEFERRED; every other form, NOT DEFERRABLE INITIALLY DEFERRED included, is checked at the end of each statement. Written as a column constraint, the clause applies to the foreign key defined last before it in the table definition and has no effect when there is none. Source: https://sqlite.org/foreignkeys.html#fk_deferred. Status: Implemented.
$semantics = new \SqlSemantics\Platform\Sqlite\Semantics();
$deferred = $semantics->analyze('CREATE TABLE c (p REFERENCES parent DEFERRABLE INITIALLY DEFERRED)')->statement->columns[0]->constraints[1];
$immediate = $semantics->analyze('CREATE TABLE c (p REFERENCES parent NOT DEFERRABLE INITIALLY DEFERRED)')->statement->columns[0]->constraints[1];
[$deferred->deferred(), $immediate->deferred()] // => [true, false]Properties§
public bool $deferrablepublic InitialMode|null $initially = nullMethods§
public function __construct(public bool $deferrable, public InitialMode|null $initially = null)Parameters
$deferrable | bool | Whether DEFERRABLE is written without NOT |
$initially | InitialMode|null | The word written after INITIALLY |
public function deferred(): boolTells whether the foreign key is checked at the end of the transaction.
Returns
boolTest cases 1
Calls 1
- class-const InitialMode::Deferred() line 48
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): voidDerives nothing: the clause has no operand.
Parameters
$derivation | Derivation | |
$scope | ConstraintScope |
public function render(Output $out): voidTest cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 3
Relations§
Instantiated in 2
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\ForeignKeyRule::deferrability() packages/sql-semantics-sqlite/src/Lowering/Definition/ForeignKeyRule.php:122
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\ForeignKeyRule::deferrability() packages/sql-semantics-sqlite/src/Lowering/Definition/ForeignKeyRule.php:123
Type declarations 3
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\ForeignKeyRule packages/sql-semantics-sqlite/src/Lowering/Definition/ForeignKeyRule.php:117
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\ForeignKeyRule packages/sql-semantics-sqlite/src/Lowering/Definition/ForeignKeyRule.php:133
- type SqlSemantics\Platform\Sqlite\Statement\Schema\Table\ForeignKey packages/sql-semantics-sqlite/src/Statement/Schema/Table/ForeignKey.php:47