classSublinks
final class Sublinks
Types the sublinks: a query, or an array, used inside an expression.
Rule: PG-SUBLINK-001. A scalar subquery of one column has the column's type; of several columns it is a row, which only a row comparison accepts; of none it is reported. ARRAY(query) needs one column and gives an array of its type, an array column giving the same array type. A comparison with the rows of a query (IN, ANY, SOME, ALL) applies the operator to the value and the one column, or field by field to a row and as many columns; another number of columns is reported. A comparison with the elements of an array applies the operator to the value and the element type; a string constant on the right is read as an array of the value's type, and another non-array type is reported. A query of an open shape makes the result depend on its missing inputs. Termination: one pass over the columns. Source: https://www.postgresql.org/docs/17/functions-subquery.html, https://www.postgresql.org/docs/17/functions-comparisons.html, https://www.postgresql.org/docs/17/sql-expressions.html#SQL-SYNTAX-SCALAR-SUBQUERIES. Status: Implemented.
Methods§
public function value(Derivation $derivation, QueryFact $fact, string $construct): TypeFactTypes the value of a scalar subquery.
Parameters
$derivation | Derivation | |
$fact | QueryFact | |
$construct | string |
Returns
Test cases 1
Called from 1
Calls 5
- method-call Sublinks::slots() line 50
- method-call Sublinks::arity() line 55
- function-call
countline 58 - new Known line 58
- new Composite line 58
public function array(Derivation $derivation, QueryFact $fact): TypeFactTypes the array an ARRAY subquery builds.
Parameters
$derivation | Derivation | |
$fact | QueryFact |
Returns
Test cases 1
Called from 1
Calls 5
- method-call Sublinks::slots() line 66
- function-call
countline 70 - method-call Sublinks::arity() line 71
- new Known line 78
- new ArrayOf line 78
public function compared(
Derivation $derivation,
TypeFact $operand,
OperatorName|string $operator,
QueryFact $fact,
): TypeFactTypes the comparison of a value with the rows of a query.
Parameters
$derivation | Derivation | |
$operand | TypeFact | |
$operator | OperatorName|string | |
$fact | QueryFact |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\InSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/InSubquery.php:60
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\QuantifiedSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/QuantifiedSubquery.php:65
Calls 8
- method-call Sublinks::slots() line 86
- new OperatorTyping line 90
- function-call
countline 93 - method-call OperatorTyping::named() line 93
- method-call Sublinks::arity() line 93
- new Known line 98
- class-const Builtin::Bool() line 98
- method-call OperatorTyping::both() line 100
public function elements(
Derivation $derivation,
TypeFact $operand,
OperatorName $operator,
TypeFact $array,
): TypeFactTypes the comparison of a value with the elements of an array.
Parameters
$derivation | Derivation | |
$operand | TypeFact | |
$operator | OperatorName | |
$array | TypeFact |
Returns
Test cases 1
Called from 1
Calls 9
- new OperatorTyping line 111
- method-call Categories::builtin() line 115
- new Categories line 115
- class-const Builtin::Unknown() line 115
- method-call OperatorTyping::named() line 116
- new Known line 119
- new OperandMismatch line 124
- method-call Derivation::report() line 125
- new Invalid line 127
public function slots(QueryFact $fact): list<OutputSlot>|DependentAnswers the output slots of a query, or its dependence on missing inputs when its shape is open.
Parameters
$fact | QueryFact |
Returns
list<OutputSlot>|DependentTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::value() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::array() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:66
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::compared() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:86
Calls 2
- method-call QueryFact::fields() line 137
- new Dependent line 139
public function arity(
Derivation $derivation,
string $construct,
int $expected,
int $actual,
): InvalidReports a wrong number of columns and answers its invalid fact.
Parameters
$derivation | Derivation | |
$construct | string | |
$expected | int | |
$actual | int |
Returns
Test cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::value() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:55
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::array() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::compared() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:93
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::compared() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:96
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
SublinksTest::testArityReportsTheProblemcallsSublinksTest::testArrayIsAnArrayOfTheColumnTypecallsSublinksTest::testComparedReportsAWrongNumberOfColumnscallsSublinksTest::testElementsReadsAStringAsAnArrayOfTheValueTypecallsSublinksTest::testSlotsDependOnAnOpenShapecallsSublinksTest::testValueIsARowForSeveralColumnscalls
Relations§
Instantiated in 5
- new SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\ArraySubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/ArraySubquery.php:61
- new SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\InSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/InSubquery.php:60
- new SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\QuantifiedArray::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/QuantifiedArray.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\QuantifiedSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/QuantifiedSubquery.php:65
- new SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\ScalarSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/ScalarSubquery.php:64
Method calls 5
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\ArraySubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/ArraySubquery.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\InSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/InSubquery.php:60
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\QuantifiedArray::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/QuantifiedArray.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\QuantifiedSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/QuantifiedSubquery.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Expression\Subquery\ScalarSubquery::deriveScalar() packages/sql-semantics-postgres/src/Statement/Expression/Subquery/ScalarSubquery.php:64