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

A test for rows: EXISTS (SELECT …) (Item_exists_subselect).

Rule: MYSQL-EXISTS-001. Facts: 1 when the subquery returns a row and 0 otherwise, an integer that is never NULL; the columns of the subquery do not matter. Terminates: the query is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/exists-and-not-exists-subqueries.html. Status: Implemented.

Testing for rowsdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE EXISTS (SELECT 1)');
    $query->facts->scalar($query->statement->where)->nullability // => \SqlSemantics\Platform\MySql\Model\Statement\Type\Nullability::NotNull

Properties§

public Query $query

Methods§

public function __construct(public Query $query)

Parameters

$queryQueryThe query
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the query; the test is never NULL.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes EXISTS and the query in parentheses.

Parameters

$outOutput
Calls 1

Test cases 3§

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

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 2