classDomainChecks
final class DomainChecks
Checks the constraints written for a domain.
Rule: PG-DOMAIN-CHECK-001. A domain accepts NULL, NOT NULL, DEFAULT and CHECK constraints and a collation. UNIQUE, PRIMARY KEY, EXCLUDE and REFERENCES are not possible for domains, GENERATED and IDENTITY are not supported, nor is any deferrability attribute; NULL together with NOT NULL conflict, a second DEFAULT is rejected, and a CHECK constraint of a domain cannot be NO INHERIT. A constraint added by ALTER DOMAIN follows the same rules. Termination: one pass over a finite list. Source: https://www.postgresql.org/docs/17/sql-createdomain.html, https://www.postgresql.org/docs/17/sql-alterdomain.html. Status: Implemented.
Methods§
public function constraints(Derivation $derivation, list<Clause> $constraints): voidReports the problems of the constraints of CREATE DOMAIN or of the one constraint ALTER DOMAIN adds.
Parameters
$derivation | Derivation | |
$constraints | list<Clause> |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\AlterDomainConstraint::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/AlterDomainConstraint.php:52
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\CreateDomain::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/CreateDomain.php:63
Calls 13
- method-call Derivation::report() line 43
- new CatalogMisuse line 43
- class-const CatalogMisuseRule::DomainDeferrability() line 43
- method-call DomainChecks::rule() line 49
- class-const CatalogMisuseRule::DomainCheckNoInherit() line 54
- function-call
in_arrayline 57 - class-const ConstraintKind::Null() line 57
- class-const ConstraintKind::NotNull() line 57
- class-const CatalogMisuseRule::DomainNullConflict() line 58
- function-call
countline 60 - function-call
array_keysline 60 - class-const ConstraintKind::Default() line 60
- class-const CatalogMisuseRule::DomainDefaults() line 61
public function rule(ConstraintKind $kind): ?CatalogMisuseRuleAnswers the rule a constraint of a kind breaks when written for a domain, or null when a domain accepts it.
Parameters
$kind | ConstraintKind |
Returns
Test cases 2
Called from 1
Calls 15
- class-const ConstraintKind::Null() line 71
- class-const ConstraintKind::NotNull() line 71
- class-const ConstraintKind::Default() line 71
- class-const ConstraintKind::Check() line 71
- class-const ConstraintKind::Identity() line 72
- class-const ConstraintKind::Generated() line 72
- class-const CatalogMisuseRule::DomainGenerated() line 72
- class-const ConstraintKind::PrimaryKey() line 73
- class-const CatalogMisuseRule::DomainPrimaryKey() line 73
- class-const ConstraintKind::Unique() line 74
- class-const CatalogMisuseRule::DomainUnique() line 74
- class-const ConstraintKind::Exclusion() line 75
- class-const CatalogMisuseRule::DomainExclusion() line 75
- class-const ConstraintKind::ForeignKey() line 76
- class-const CatalogMisuseRule::DomainForeignKey() line 76
public function attributes(
Derivation $derivation,
list<ConstraintAttribute> $attributes,
bool $check,
): voidReports the attributes a constraint written with ConstraintAttributeSpec cannot carry.
Deferral is rejected for CHECK and NOT NULL, NOT VALID for NOT NULL, and NO INHERIT for the CHECK constraint of a domain; NOT DEFERRABLE and INITIALLY IMMEDIATE state the defaults and are accepted.
Parameters
$derivation | Derivation | |
$attributes | list<ConstraintAttribute> | |
$check | bool |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\DomainCheck::deriveClause() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/DomainCheck.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\DomainNotNull::deriveClause() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/DomainNotNull.php:53
Calls 11
- class-const ConstraintAttribute::Deferrable() line 94
- class-const ConstraintAttribute::InitiallyDeferred() line 94
- class-const CatalogMisuseRule::MarkedDeferrable() line 94
- class-const ConstraintAttribute::NotValid() line 95
- class-const CatalogMisuseRule::MarkedNotValid() line 95
- class-const ConstraintAttribute::NoInherit() line 96
- class-const CatalogMisuseRule::DomainCheckNoInherit() line 96
- class-const ConstraintAttribute::NotDeferrable() line 97
- class-const ConstraintAttribute::InitiallyImmediate() line 97
- method-call Derivation::report() line 100
- new CatalogMisuse line 100
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 4
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\AlterDomainConstraint::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/AlterDomainConstraint.php:52
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\CreateDomain::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/CreateDomain.php:63
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\DomainCheck::deriveClause() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/DomainCheck.php:57
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\DomainNotNull::deriveClause() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/DomainNotNull.php:53
Method calls 4
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\AlterDomainConstraint::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/AlterDomainConstraint.php:52
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\CreateDomain::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/CreateDomain.php:63
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\DomainCheck::deriveClause() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/DomainCheck.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Domain\DomainNotNull::deriveClause() packages/sql-semantics-postgres/src/Statement/Catalog/Domain/DomainNotNull.php:53