packages/sql-semantics-mysql/src/Statement/Expression/Operator/UnaryOperator.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Statement\Expression\Operator;
6
7/**
8 * The prefix operators of the simple_expr level: `+`, `-`, `~` and the tight logical negation `!`.
9 *
10 * Under HIGH_NOT_PRECEDENCE the keyword NOT is the tight negation and is
11 * written `!`. Each case holds the written operator.
12 * Source: https://dev.mysql.com/doc/refman/8.4/en/operator-precedence.html,
13 * https://dev.mysql.com/doc/refman/8.4/en/sql-mode.html#sqlmode_high_not_precedence.
14 *
15 * @visibility public
16 * @example Reading a unary minus
17 * $query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE -a < 0');
18 * $query->statement->where->left->operator // => \SqlSemantics\Platform\MySql\Statement\Expression\Operator\UnaryOperator::Minus
19 */
20enum UnaryOperator: string
21{
22 case Plus = '+';
23 case Minus = '-';
24 case Invert = '~';
25 case Not = '!';
26}
27