classVisibility
final class Visibility
Tells which relations of a query level a qualifier or a star reaches.
Rule: PG-VISIBILITY-001. A relation the hidden list of which holds QUALIFIED_ONLY is visible as a relation name but not for unqualified column names and not to *: PostgreSQL treats the tables inside a join that has no alias this way, and the alias of USING columns. Such a relation also lists every slot position as hidden, so that the core column lookup skips it for unqualified names; its system columns are not found by an unqualified name either (colNameToVar skips a namespace item whose columns are not visible, and a join has no system columns), so an unqualified name is looked up in a view of the positions without them. A qualifier reaches a relation by its alias, or, without one, by its name and the schema written; * reaches every other relation and skips its hidden slots. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-FROM. Status: Implemented.
Constants§
public const QUALIFIED_ONLY = -1The hidden-list entry that marks a relation as reachable with a qualifier only.
Methods§
public function qualifiedOnly(VisibleRelation $relation): VisibleRelationAnswers the relation reachable by a qualifier only.
Parameters
$relation | VisibleRelation |
Returns
Test cases 4
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:86
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:89
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:92
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\PseudoRelations::scope() packages/sql-semantics-postgres/src/Rules/Table/PseudoRelations.php:42
Calls 4
- method-call Visibility::restricted() line 44
- new VisibleRelation line 48
- class-const Visibility::QUALIFIED_ONLY() line 48
- function-call
array_keysline 48
public function unqualified(Environment $environment): EnvironmentAnswers the positions an unqualified column name searches: the same, without the system columns of relations reachable with a qualifier only.
Parameters
$environment | Environment |
Returns
Test cases 2
Called from 2
Calls 4
- function-call
array_reverseline 62 - method-call Visibility::restricted() line 65
- new VisibleRelation line 66
- new Environment line 71
public function restricted(VisibleRelation $relation): boolTells whether a relation is reachable with a qualifier only.
Parameters
$relation | VisibleRelation |
Returns
boolTest cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::all() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:56
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Visibility::qualifiedOnly() packages/sql-semantics-postgres/src/Rules/Resolution/Visibility.php:44
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Visibility::unqualified() packages/sql-semantics-postgres/src/Rules/Resolution/Visibility.php:65
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Visibility::star() packages/sql-semantics-postgres/src/Rules/Resolution/Visibility.php:114
Calls 2
- function-call
in_arrayline 82 - class-const Visibility::QUALIFIED_ONLY() line 82
public function admits(
Environment $scope,
VisibleRelation $relation,
QualifiedName $qualifier,
): boolTells whether a qualifier names a relation.
Parameters
$scope | Environment | |
$relation | VisibleRelation | |
$qualifier | QualifiedName |
Returns
boolTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Limits::locked() packages/sql-semantics-postgres/src/Rules/Query/Limits.php:108
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::named() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:125
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::qualified() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:85
public function star(list<VisibleRelation> $relations): RowShapeAnswers the row * selects from the relations of a level: every slot that is not hidden, of every relation that is not qualified-only.
Parameters
$relations | list<VisibleRelation> |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:100
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:53
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:54
Calls 4
- method-call Visibility::restricted() line 114
- function-call
array_pushline 117 - method-call Visibility::unhidden() line 117
- new RowShape line 121
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
VisibilityTest::testAdmitsMatchesTheNameAndSchemacallsVisibilityTest::testQualifiedOnlyHidesEverySlotcallsVisibilityTest::testRestrictedTellsAQualifiedOnlyRelationcallsVisibilityTest::testStarSkipsQualifiedOnlyRelationscallsVisibilityTest::testUnhiddenSkipsHiddenSlotscallsVisibilityTest::testUnqualifiedDropsTheSystemColumnsOfQualifiedOnlyRelationscallsVisibilityTest::testUnqualifiedKeepsAnEnvironmentWithoutQualifiedOnlyRelationscalls
Relations§
Instantiated in 9
- new SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnFacts::derive() packages/sql-semantics-postgres/src/Rules/Expression/ColumnFacts.php:65
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Limits::locked() packages/sql-semantics-postgres/src/Rules/Query/Limits.php:108
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::named() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:125
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::group() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:85
- new SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::all() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:52
- new SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::qualified() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:81
- new SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:100
- new SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:52
- new SqlSemantics\Platform\PostgreSql\Rules\Table\PseudoRelations::scope() packages/sql-semantics-postgres/src/Rules/Table/PseudoRelations.php:42
Method calls 13
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnFacts::derive() packages/sql-semantics-postgres/src/Rules/Expression/ColumnFacts.php:65
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Limits::locked() packages/sql-semantics-postgres/src/Rules/Query/Limits.php:108
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::named() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:125
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::group() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:85
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::all() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:56
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::qualified() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:85
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:100
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:53
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:54
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:86
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:89
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:92
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\PseudoRelations::scope() packages/sql-semantics-postgres/src/Rules/Table/PseudoRelations.php:42