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

A name used as a value: a request to resolve it as a column at its position.

The node holds the decoded column name and its optional table and database qualifiers. Which occurrence and declaration it denotes is a fact of the operation that contains it.

Rule: MYSQL-COLUMN-USE-001. Facts: the resolution of MYSQL-COLUMN-LOOKUP-001 over the relation occurrences of the position and, after them, the select list aliases the position may use; a use resolved to a slot or to an aliased item has the type and NULL fact of that slot or item; a conditional use depends on its missing inputs; a missing or ambiguous use is invalid and is a diagnostic. Terminates: the lookup is finite. Source: https://dev.mysql.com/doc/refman/8.4/en/identifier-qualifiers.html, https://dev.mysql.com/doc/refman/8.4/en/problems-with-alias.html. Status: Implemented.

Reading a qualified column usedoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT shop.t.a FROM shop.t');
    $use = $query->statement->items[0]->expression;
    [$use->qualifier?->schema?->value, $use->qualifier?->name->value, $use->name->value] // => ['shop', 't', 'a']

Properties§

public Name $name
public QualifiedName|null $qualifier = null
public OptionalWords $dot = OptionalWords::Omitted

Methods§

public function __construct(
    public Name $name,
    public QualifiedName|null $qualifier = null,
    public OptionalWords $dot = OptionalWords::Omitted,
)

Parameters

$nameNameThe column name
$qualifierQualifiedName|nullThe table the use is qualified with, and the database of that table when written
$dotOptionalWordsWhether the table qualifier is written after a leading dot, `.t.a` (MySQL 5.6 and 5.7)
Calls 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Resolves the name in the environment and derives its facts from the slot found.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the qualifier parts and the name.

Parameters

$outOutput
Calls 6

Test cases 61§

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

Dedicated tests 2
Other tests reaching this symbol 59

Relations§

Instantiated in 1
Constant reads 1
Type checks 14
Type declarations 7