classDefaultLiteral
final class DefaultLiteral
implements ColumnConstraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A DEFAULT column constraint whose value is a literal, optionally signed.
Rule: SQLITE-COLUMN-DEFAULT-LITERAL-001. The literal is NULL, a number, a string, a BLOB or one of CURRENT_TIME, CURRENT_DATE and CURRENT_TIMESTAMP. A minus sign negates the literal; a plus sign is read and changes nothing. The grammar accepts a sign before every literal, a string included. The CURRENT_ keywords are evaluated when a row is inserted. Source: https://sqlite.org/lang_createtable.html#the_default_clause. Status: Implemented.
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (a INT DEFAULT -1)');
$default = $create->statement->columns[0]->constraints[0];
[$default->sign, $default->literal->digits] // => [\SqlSemantics\Platform\Sqlite\Statement\Type\NumberSign::Minus, '1']Properties§
public Scalar $literalpublic NumberSign|null $sign = nullMethods§
public function __construct(public Scalar $literal, public NumberSign|null $sign = null)Parameters
$literal | Scalar | The literal; one of the literal expression classes |
$sign | NumberSign|null | The sign written before the literal |
Calls 2
- static-call Check::input() line 42
- function-call
str_starts_withline 42
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): voidDerives the literal; it sees no column.
Parameters
$derivation | Derivation | |
$scope | ConstraintScope |
Calls 1
- method-call Derivation::scalar() line 50
public function render(Output $out): voidWrites the clause.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 58
- method-call Output::symbol() line 60
- method-call Output::node() line 62
Test cases 7§
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 4
Relations§
Instantiated in 3
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\ColumnRule::default() packages/sql-semantics-sqlite/src/Lowering/Definition/ColumnRule.php:129
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\ColumnRule::default() packages/sql-semantics-sqlite/src/Lowering/Definition/ColumnRule.php:130
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\ColumnRule::default() packages/sql-semantics-sqlite/src/Lowering/Definition/ColumnRule.php:131
Type checks 4
- 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:63
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\LiteralDefaults::literal() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/LiteralDefaults.php:75
- 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