final class InSubquery
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A membership test against the rows of a query: a [NOT] IN (SELECT …).

Mirrors PostgreSQL's SubLink node of kind ANY_SUBLINK with the operator =; NOT IN is the negation of that test.

Rule: PG-IN-SUBQUERY-001. The query is derived in the environment of the expression; it returns one column, or as many as the fields of a row constructor on the left. Facts: the type of = over the value and the column (PG-OPERATOR-TYPING-001); NULL when no row matches and a compared value is NULL, so the result can be NULL. The value must keep its place before IN (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-subquery.html#FUNCTIONS-SUBQUERY-IN. Status: Implemented.

Reading a negated membership testdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 NOT IN (SELECT 2)');
    [$query->field(0)->expression->negated, $query->field(0)->type->descriptor->name()] // => [true, 'boolean']

Properties§

public Scalar $operand
public bool $negated
public Query $query

Methods§

public function __construct(public Scalar $operand, public bool $negated, public Query $query)

Parameters

$operandScalarThe tested value
$negatedboolWhether NOT is written
$queryQueryThe query inside the parentheses
Calls 4
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the value and the query, and the comparison of the value with its rows.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 6
public function render(Output $out): void

Writes the value, [NOT] IN and the query in parentheses.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 3§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3

Relations§

Instantiated in 1
Type checks 1