final class DefaultExpression
    implements Constraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A DEFAULT column constraint: the value a column takes when none is given.

Mirrors CONSTR_DEFAULT with raw_expr. The grammar reads a b_expr, so the expression has no boolean, IS, pattern or subquery operator outside parentheses. "The value is any variable-free expression": the expression sees no column, so it is derived where no relation is visible. Source: https://www.postgresql.org/docs/17/sql-createtable.html.

Reading a defaultdoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int DEFAULT 1 + 2)');
    $create->toString() // => 'CREATE TABLE t (a INT DEFAULT 1 + 2)'

Properties§

public Scalar $value
public Name|null $name = null

Methods§

public function __construct(public Scalar $value, public Name|null $name = null)

Parameters

$valueScalarThe default expression; a `b_expr`
$nameName|nullThe constraint name
Calls 3
public function kind(): ConstraintKind

Answers the kind of the constraint.

Calls 1
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the expression where no column is visible.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the constraint.

Parameters

$outOutput
Calls 3

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2

Relations§

Instantiated in 1
Constant reads 6