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.

Reading a negative defaultdoctest
$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 $literal
public NumberSign|null $sign = null

Methods§

public function __construct(public Scalar $literal, public NumberSign|null $sign = null)

Parameters

$literalScalarThe literal; one of the literal expression classes
$signNumberSign|nullThe sign written before the literal
Calls 2
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): void

Derives the literal; it sees no column.

Parameters

$derivationDerivation
$scopeConstraintScope
Calls 1
public function render(Output $out): void

Writes the clause.

Parameters

$outOutput
Calls 3

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
Type checks 4
Type declarations 2