classColumnCheck
final class ColumnCheck
implements Constraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A CHECK column constraint: a condition every row satisfies.
Mirrors CONSTR_CHECK with raw_expr and is_no_inherit. The condition is derived where the columns of the table are visible (PG-TABLE-CONDITION-001); a column constraint may refer to any column. Source: https://www.postgresql.org/docs/17/sql-createtable.html, https://www.postgresql.org/docs/17/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS.
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int CHECK (a > 0) NO INHERIT)');
$check = $create->statement->definition->elements[0]->qualifiers[0];
[$check->noInherit, $create->facts->scalar($check->condition->left)->resolution->slot->column === $create->declarations()[0]->columns[0]] // => [true, true]Properties§
public Scalar $conditionpublic bool $noInherit = falsepublic Name|null $name = nullMethods§
public function __construct(
public Scalar $condition,
public bool $noInherit = false,
public Name|null $name = null,
)Parameters
$condition | Scalar | The condition |
$noInherit | bool | Whether NO INHERIT is written: the constraint does not apply to child tables |
$name | Name|null | The constraint name |
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidDerives the condition against the table.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 2
- method-call Conditions::derive() line 58
- new Conditions line 58
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 3
- method-call Writing::constraintName() line 66
- new Writing line 66
- method-call Output::keyword() line 67
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.