final class SortScopes
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Derives the items of ORDER BY and GROUP BY.

Rule: MYSQL-SORT-SCOPE-001. A select list position (MYSQL-ORDINAL-001) denotes the output field at that position. An ORDER BY item that is a bare unqualified name equal to the alias of a select list item denotes that item, because ORDER BY searches the select list first. Every other item sees the columns of the FROM clause first and the aliases of the select list after them, which is how GROUP BY, HAVING and expressions in ORDER BY resolve. Terminates: one pass over the items. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html ("MySQL resolves an unqualified column or alias reference in ORDER BY clauses by searching in the select_expr values, then in the columns of the tables in the FROM clause. For GROUP BY or HAVING clauses, it searches the FROM clause before searching in the select_expr values"). Status: Implemented.

Methods§

public function derive(
    list<OrderItem> $items,
    Derivation $derivation,
    Environment $environment,
    list<Field|OpenStar> $projection,
    bool $aliasFirst,
): list<ScalarFact>

Derives the items in the given environment, whose aliases are the aliased output fields.

Parameters

$itemslist<OrderItem>
$derivationDerivation
$environmentEnvironment
$projectionlist<Field|OpenStar>The output of the query, in order
$aliasFirstboolWhether a bare name looks at the aliases first, as in ORDER BY

Returns

list<ScalarFact> The facts of the items, in order
Called from 3
Calls 7
public function word(Scalar $expression): ?Name

Answers the name of an item that is a bare unqualified column reference, possibly in parentheses.

Parameters

$expressionScalar

Returns

Test cases 1
Called from 1

Test cases 2§

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

Dedicated tests 2

Relations§

Instantiated in 7
Method calls 7