classUserAssignment
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.
$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 $variablepublic Scalar $valueMethods§
public function __construct(public UserVariable $variable, public Scalar $value)Parameters
$variable | UserVariable | The assigned variable |
$value | Scalar | The assigned value |
public function deriveItem(Derivation $derivation): voidDerives the variable and the value.
Parameters
$derivation | Derivation |
Calls 4
- method-call Derivation::scalar() line 46
- method-call Derivation::environment() line 46
- method-call Operands::single() line 47
- new Operands line 47
public function render(Output $out): voidWrites the variable, an equals sign and the value.
Parameters
$out | Output |
Calls 1
- method-call Output::node() line 55
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
ProgramFactsTest::testBodyKeepsAProgramStatementAndAnSqlStatementcallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::providerFoundIsFalseWithoutReturncallsReturnSearchTest::testNestedAnswersNothingForAStatementWithoutNestedStatementscallsReturnSearchTest::testNestedAnswersTheElseStatementsBeforeTheBranchStatementscallsReturnSearchTest::testNestedAnswersTheStatementsAndHandlerStatementsOfABlockcalls