classRelationTargets
final class RelationTargets
Resolves the relations and columns a generic object command names.
Rule: PG-OBJECT-RELATION-001. A table, view, materialized view or foreign table named by DROP, COMMENT, SECURITY LABEL or an ALTER command, the table a policy, rule, trigger or table constraint belongs to, and the table of a column are resolved along the search path (CORE-TABLE-LOOKUP-001) and recorded as the relation fact of the object reference: a declared relation with its columns, an undeclared one as an open shape naming the missing declaration, a missing or conflicting one as a diagnostic. A relation that IF EXISTS lets the server skip is recorded without a table and is no diagnostic. A dotted relation name of more than three parts is reported. A column is named by a dotted name whose last part is the column: one part is reported as unqualified, more than four parts as an improper relation name, and a column the declared complete relation certainly lacks is reported. Renaming a column to a name the relation certainly has is reported. Indexes and sequences are not declarations the context can hold and are not resolved. Terminates: one lookup per reference. Source: https://www.postgresql.org/docs/17/sql-comment.html, https://www.postgresql.org/docs/17/sql-droptable.html, https://www.postgresql.org/docs/17/sql-altertable.html, https://www.postgresql.org/docs/17/ddl-schemas.html#DDL-SCHEMAS-PATH. Status: Implemented.
Methods§
public function resolve(
ObjectKind $kind,
ObjectReference $object,
bool $ifExists,
Derivation $derivation,
): ?RelationFactResolves the relation an object reference names, if its kind names one, and records the fact; answers it.
Parameters
$kind | ObjectKind | |
$object | ObjectReference | |
$ifExists | bool | |
$derivation | Derivation |
Returns
Test cases 2
Called from 1
Calls 10
- function-call
in_arrayline 60 - class-const ObjectForms::RELATION() line 60
- class-const ObjectKind::Column() line 61
- method-call RelationTargets::column() line 62
- method-call RelationTargets::dotted() line 65
- method-call RelationTargets::record() line 68
- class-const ObjectKind::Policy() line 70
- class-const ObjectKind::Rule() line 70
- class-const ObjectKind::Trigger() line 70
- class-const ObjectKind::Constraint() line 70
public function dotted(
ObjectReference $reference,
DottedName $name,
bool $ifExists,
Derivation $derivation,
): RelationFactResolves a relation written as a dotted name and records the fact on the reference.
Parameters
$reference | ObjectReference | |
$name | DottedName | |
$ifExists | bool | |
$derivation | Derivation |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::resolve() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:65
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::resolve() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:71
Calls 7
- method-call DottedName::qualified() line 82
- method-call Derivation::report() line 84
- new ImproperName line 84
- method-call Derivation::target() line 86
- new RelationFact line 86
- new RowShape line 86
- method-call RelationTargets::record() line 89
public function record(
ObjectReference $reference,
QualifiedName $name,
bool $ifExists,
Derivation $derivation,
): RelationFactResolves a relation name and records the fact on the reference.
Parameters
$reference | ObjectReference | |
$name | QualifiedName | |
$ifExists | bool | |
$derivation | Derivation |
Returns
Test cases 4
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::resolve() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:68
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::resolve() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::dotted() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:89
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::column() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:128
Calls 9
- method-call Derivation::table() line 97
- method-call Derivation::environment() line 97
- method-call Derivation::target() line 99
- new RelationFact line 99
- new RowShape line 99
- new OutputSlot line 105
- method-call DeclaredTyping::fact() line 105
- new DeclaredTyping line 105
- new IncompleteMembers line 107
public function column(DottedName $name, Derivation $derivation): RelationFactResolves the table of a column written as a dotted name, records the fact on the name and reports a column the table certainly lacks.
Parameters
$name | DottedName | |
$derivation | Derivation |
Returns
Test cases 1
Called from 1
Calls 15
- function-call
countline 121 - method-call Derivation::report() line 123
- new ObjectProblem line 123
- class-const ObjectProblemKind::UnqualifiedColumn() line 123
- class-const ObjectProblemKind::ImproperRelation() line 123
- method-call RelationTargets::spelled() line 123
- method-call Derivation::target() line 125
- new RelationFact line 125
- new RowShape line 125
- method-call DottedName::qualified() line 127
- new DottedName line 127
- function-call
array_sliceline 127 - new QualifiedName line 127
- method-call RelationTargets::record() line 128
- method-call RelationTargets::member() line 129
public function member(
RelationFact $fact,
Name $column,
QualifiedName $table,
Derivation $derivation,
): voidReports a column that a declared complete relation certainly lacks.
Parameters
$fact | RelationFact | |
$column | Name | |
$table | QualifiedName | |
$derivation | Derivation |
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::column() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:129
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::deriveStatement() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:83
Calls 3
- method-call RelationTargets::has() line 139
- method-call Derivation::report() line 140
- new MissingColumn line 140
public function renamed(RelationFact $fact, Name $column, Derivation $derivation): voidReports renaming a column to a name a declared relation certainly has.
Parameters
$fact | RelationFact | |
$column | Name | |
$derivation | Derivation |
Test cases 1
Called from 1
Calls 4
- method-call RelationTargets::has() line 149
- method-call Derivation::report() line 150
- new ObjectProblem line 150
- class-const ObjectProblemKind::ColumnExists() line 150
public function has(RelationFact $fact, Name $column, Derivation $derivation): ?boolTells whether the relation of a fact has a column of the name: true, false, or null when its declaration does not tell.
Parameters
$fact | RelationFact | |
$column | Name | |
$derivation | Derivation |
Returns
?boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::member() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:139
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::renamed() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:149
Test cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
RelationTargetsTest::testColumnReportsAMissingColumncallsRelationTargetsTest::testDottedReportsAnImproperNamecallsRelationTargetsTest::testHasAnswersNullWithoutADeclarationcallsRelationTargetsTest::testMemberAcceptsADeclaredColumncallsRelationTargetsTest::testRecordKeepsAnUndeclaredRelationOpencallsRelationTargetsTest::testRenamedReportsAnExistingColumncallsRelationTargetsTest::testResolveIgnoresKindsThatNameNoRelationcallsRelationTargetsTest::testResolveRecordsTheTableOfAMembercallsRelationTargetsTest::testSpelledJoinsThePartscalls
Relations§
Instantiated in 2
Method calls 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\ObjectFacts::derive() packages/sql-semantics-postgres/src/Rules/Routine/ObjectFacts.php:49
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::deriveStatement() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:83
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::deriveStatement() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:84