classTableCheck
final class TableCheck
implements Constraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A CHECK table constraint: a condition every row satisfies.
Mirrors CONSTR_CHECK with raw_expr, skip_validation (NOT VALID) and is_no_inherit. The condition is derived where the columns of the table are visible (PG-TABLE-CONDITION-001); the attributes are checked by PG-CONSTRAINT-ATTRIBUTES-001. Source: https://www.postgresql.org/docs/17/sql-createtable.html.
$alter = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int, CONSTRAINT positive CHECK (a > 0) NOT VALID)');
[$alter->statement->definition->elements[1]->name->value, $alter->statement->definition->elements[1]->attributes] // => ['positive', [\SqlSemantics\Platform\PostgreSql\Statement\Constraint\ConstraintAttribute::NotValid]]Properties§
public list<ConstraintAttribute> $attributespublic Scalar $conditionpublic Name|null $name = nullMethods§
public function __construct(
public Scalar $condition,
list<ConstraintAttribute> $attributes = [],
public Name|null $name = null,
)Parameters
$condition | Scalar | The condition |
$attributes | list<ConstraintAttribute> | The attributes in the order written |
$name | Name|null | The constraint name |
Calls 2
- method-call Attributes::checked() line 50
- new Attributes line 50
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidDerives the condition against the table and checks the attributes.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 4
- method-call Conditions::derive() line 66
- new Conditions line 66
- method-call Attributes::report() line 67
- new Attributes line 67
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 4
- new Writing line 75
- method-call Writing::constraintName() line 76
- method-call Output::keyword() line 77
- method-call Writing::sequence() line 78
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.