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

A comparison of two operands, in the order written.

Comparisons belong to the bool_pri level and associate to the left; the right operand is a predicate (MYSQL-PRECEDENCE-001). An operand that would be read differently without a grouping, such as a comparison on the right or a variable assignment on the left, is rejected (Item_func_eq, Item_func_equal, Item_func_ne, Item_func_lt, …).

Rule: MYSQL-COMPARISON-001. Facts: a comparison yields 1, 0 or NULL, an integer; it can be NULL when an operand can, except <=>, which never is. Two rows are compared element by element and must have the same width (MYSQL-OPERAND-COLUMNS-001). Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/comparison-operators.html, https://dev.mysql.com/doc/refman/8.4/en/row-subqueries.html. Status: Implemented.

Reading both operandsdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a >= 10');
    [$query->statement->where->left->name->value, $query->statement->where->right->text] // => ['a', '10']

Properties§

public Scalar $left
public Scalar $right

Methods§

public function __construct(
    public ComparisonOperator $operator,
    public Scalar $left,
    public Scalar $right,
)

Parameters

$operatorComparisonOperatorThe operator
$leftScalarThe left operand
$rightScalarThe right operand
Calls 6
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives both operands and combines their NULL facts.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the operands around the operator.

Parameters

$outOutput
Calls 1

Test cases 47§

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

Dedicated tests 9
Other tests reaching this symbol 38

Relations§

Instantiated in 2
Type checks 1