classDefaultExpression
final class DefaultExpression
implements ColumnConstraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A DEFAULT column constraint whose value is an expression in parentheses.
Rule: SQLITE-COLUMN-DEFAULT-EXPRESSION-001. The expression is evaluated once for each inserted row that gives the column no value. It must be constant: "an expression is considered constant if it contains no
- sub-queries, column or table references, bound parameters, or string
- literals enclosed in double-quotes". It is therefore derived at a position
that sees no relation, where a column name is a missing column. Source: https://sqlite.org/lang_createtable.html#the_default_clause. Status: Implemented.
(new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (a, b DEFAULT (a))') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\SemanticException: Column a does not exist.Properties§
public Scalar $expressionMethods§
public function __construct(public Scalar $expression)Parameters
$expression | Scalar | The expression written in parentheses |
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): voidDerives the expression where no column is visible.
Parameters
$derivation | Derivation | |
$scope | ConstraintScope |
Calls 1
- method-call Derivation::scalar() line 45
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 1
Other tests reaching this symbol 5
ColumnRuleTest::testDefaultLowersEveryFormOfDefaultcallsLiteralDefaultsTest::testDefaultsAnswersTheDefaultClausesInWrittenOrdercallsLiteralDefaultsTest::testLiteralTellsTheDefaultsSqliteComputesWhenAColumnIsAddedcallsLiteralDefaultsTest::testNullIsTheLiteralNullWithOrWithoutParenthesescallsColumnConstraintTest::testDeriveConstraintDerivesEachKindOfOperandInItsOwnScopecalls
Relations§
Instantiated in 1
Type checks 5
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::added() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:110
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\LiteralDefaults::defaults() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/LiteralDefaults.php:50
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\LiteralDefaults::null() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/LiteralDefaults.php:67
- instanceof SqlSemantics\Platform\Sqlite\Statement\Schema\Column\ColumnDefinition::deriveColumn() packages/sql-semantics-sqlite/src/Statement/Schema/Column/ColumnDefinition.php:113
- instanceof SqlSemantics\Platform\Sqlite\Statement\Schema\Column\ColumnDefinition::deriveColumn() packages/sql-semantics-sqlite/src/Statement/Schema/Column/ColumnDefinition.php:116
Type declarations 2
- type SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\LiteralDefaults packages/sql-semantics-sqlite/src/Rules/Definition/Expression/LiteralDefaults.php:61
- type SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\LiteralDefaults packages/sql-semantics-sqlite/src/Rules/Definition/Expression/LiteralDefaults.php:73