classInList
final class InList
implements Scalar
uses Snapshot
@visibility public.A membership test against a list of values: a [NOT] IN (v1, v2, …).
Mirrors PostgreSQL's A_Expr node of kind AEXPR_IN.
Rule: PG-IN-LIST-001. Facts: the conjunction of a = v over the values (PG-OPERATOR-TYPING-001), NULL when an operand can be. One value in parentheses that is a scalar subquery is read as IN (SELECT …) instead, so a list of one such value cannot be written. The value must keep its place before IN (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-comparisons.html#FUNCTIONS-COMPARISONS-IN-SCALAR. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 IN (1, 2, NULL)');
[count($query->field(0)->expression->values), $query->field(0)->nullability] // => [3, \SqlSemantics\Platform\PostgreSql\Model\Statement\Type\Nullability::Nullable]Properties§
public non-empty-list<Scalar> $valuespublic Scalar $operandpublic bool $negatedMethods§
public function __construct(public Scalar $operand, public bool $negated, list<Scalar> $values)Parameters
$operand | Scalar | The tested value |
$negated | bool | Whether NOT is written |
$values | list<Scalar> | The values in order; at least one |
Calls 7
- static-call Check::listOf() line 51
- class-const Scalar::class() line 51
- static-call Check::input() line 52
- method-call Precedence::before() line 52
- new Precedence line 52
- class-const Precedence::PATTERN() line 52
- function-call
countline 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the value and the list, and the comparisons of the value with each item.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 8
- method-call Derivation::scalar() line 61
- new OperatorTyping line 63
- method-call OperatorTyping::named() line 68
- function-call
array_shiftline 70 - method-call OperatorTyping::both() line 72
- new ScalarFact line 75
- method-call OperandChecks::nullability() line 75
- new OperandChecks line 75
public function render(Output $out): voidWrites the value, [NOT] IN and the list in parentheses.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::node() line 83
- method-call Output::keyword() line 85
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.