classQuantifiedSubquery
final class QuantifiedSubquery
implements Scalar
uses Snapshot
@visibility public.A comparison with every row of a query: a op ANY (SELECT …), SOME, ALL.
Mirrors PostgreSQL's SubLink node of kind ANY_SUBLINK or ALL_SUBLINK with its operator name.
Rule: PG-QUANTIFIED-SUBQUERY-001. The query is derived in the environment of the expression and returns one column, or as many as the fields of a row constructor on the left. Facts: the type of the operator over the value and the column (PG-OPERATOR-TYPING-001); the result can be NULL. The value must keep its place before the operator (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-subquery.html#FUNCTIONS-SUBQUERY-ANY-SOME. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 < ALL (SELECT 2)');
[$query->field(0)->expression->comparator->name->value, $query->field(0)->type->descriptor->name()] // => ['<', 'boolean']Properties§
public Scalar $operandpublic OperatorName|MatchKeyword $comparatorpublic Quantifier $quantifierpublic Query $queryMethods§
public function __construct(
public Scalar $operand,
public OperatorName|MatchKeyword $comparator,
public Quantifier $quantifier,
public Query $query,
)Parameters
$operand | Scalar | The compared value |
$comparator | OperatorName|MatchKeyword | The operator |
$quantifier | Quantifier | The quantifier |
$query | Query | The query inside the parentheses |
Calls 5
- static-call Check::input() line 51
- new Precedence line 52
- method-call Precedence::before() line 53
- method-call Precedence::operator() line 53
- class-const Precedence::PATTERN() line 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the value and the query, and the comparison of the value with its rows.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 8
- method-call Derivation::scalar() line 61
- method-call Derivation::query() line 62
- new OperatorName line 63
- new Name line 63
- new ScalarFact line 65
- method-call Sublinks::compared() line 65
- new Sublinks line 65
- class-const Nullability::Nullable() line 65
public function render(Output $out): voidWrites the value, the operator, the quantifier and the query in parentheses.
Parameters
$out | Output |
Test cases 1
Calls 3
- method-call Output::node() line 73
- method-call Output::keyword() line 77
- function-call
explodeline 77
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.