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

A prefix operator applied to a simple_expr: +x, -x, ~x, !x (Item_func_neg, Item_func_bit_neg, Item_func_not).

The operator binds tighter than every binary operator but looser than COLLATE, so -a COLLATE c negates the collated value (MYSQL-PRECEDENCE-001).

Rule: MYSQL-UNARY-001. Facts: unary plus has the facts of its operand (the server drops it); unary minus follows MYSQL-NUMERIC-RESULT-001; ~ is a bit operator; ! is a truth value. Each is NULL when the operand is, and takes a single value. Terminates: the operand is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/arithmetic-functions.html#operator_unary-minus, https://dev.mysql.com/doc/refman/8.4/en/bit-functions.html#operator_bitwise-invert, https://dev.mysql.com/doc/refman/8.4/en/logical-operators.html#operator_not. Status: Implemented.

Writing the tight negationdoctest
(new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE !a = 1')->toString() // => 'SELECT a FROM t WHERE ! a = 1'

Properties§

public UnaryOperator $operator
public Scalar $operand

Methods§

public function __construct(public UnaryOperator $operator, public Scalar $operand)

Parameters

$operatorUnaryOperatorThe operator
$operandScalarThe operand
Calls 4
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operand and the type of the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the operator and the operand.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 8§

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

Dedicated tests 3
Other tests reaching this symbol 5

Relations§

Instantiated in 1
Type checks 2