final class UserAssignment
    implements SetItem
    uses Snapshot
Public API: explicitly declared with @visibility public.

An assignment to a user-defined variable: SET @x = expr.

Rule: MYSQL-SET-ITEM-001 (user variables). The value is an expression, derived at a position that sees no relation; = and := are the same assignment here. The variable is derived as a session value reference. Diagnostics: none. Terminates: the value is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/user-variables.html. Status: Implemented.

Reading a user variable assignmentdoctest
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SET @total := 1 + 2');
    [$set->statement->items[0]->variable->name->value, $set->toString()] // => ['total', 'SET @total = 1 + 2']

Properties§

public UserVariable $variable
public Scalar $value

Methods§

public function __construct(public UserVariable $variable, public Scalar $value)

Parameters

$variableUserVariableThe assigned variable
$valueScalarThe assigned value
public function deriveItem(Derivation $derivation): void

Derives the variable and the value.

Parameters

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

Writes the variable, an equals sign and the value.

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 1