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

A subquery used as a value: (SELECT …), a scalar or row subquery (Item_singlerow_subselect).

The subquery sees the enclosing positions as its outer scope.

Rule: MYSQL-SCALAR-SUBQUERY-001. Facts: MYSQL-SUBQUERY-ROWS-001; a subquery of one column has its type, one of several columns is a row, and either is NULL when no row is returned. Terminates: the query is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/scalar-subqueries.html, https://dev.mysql.com/doc/refman/8.4/en/row-subqueries.html. Status: Implemented.

Comparing with a scalar subquerydoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a = (SELECT 1)');
    $query->statement->where->right instanceof \SqlSemantics\Platform\MySql\Statement\Expression\Subquery\ScalarSubquery // => true

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 with the enclosing position as outer scope, and the value it yields.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the query in parentheses.

Parameters

$outOutput
Calls 1

Test cases 7§

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 6

Relations§

Instantiated in 2