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

A logical AND, OR or XOR of two operands, in the order written (Item_cond_and, Item_cond_or, Item_func_xor).

The operators associate to the left; AND binds tighter than XOR, XOR tighter than OR (MYSQL-PRECEDENCE-001). An operand that would be read differently without a grouping is rejected.

Rule: MYSQL-LOGICAL-001. Facts: the result is 1, 0 or NULL, an integer; it can be NULL when an operand can. Both operands take a single value. Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/logical-operators.html. Status: Implemented.

Reading both operands of a conjunctiondoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a && b');
    [$query->statement->where->operator->value, $query->toString()] // => ['AND', 'SELECT a FROM t WHERE a AND b']
Refusing an operand that would associate differentlydoctest
$or = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a OR b')->statement->where;
    new \SqlSemantics\Platform\MySql\Statement\Expression\Logical(\SqlSemantics\Platform\MySql\Statement\Expression\LogicalOperator::And, $or, new \SqlSemantics\Platform\MySql\Statement\Name\ColumnUse(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('c'))) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public LogicalOperator $operator
public Scalar $left
public Scalar $right

Methods§

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

Parameters

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

Derives both operands and combines their NULL facts.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the operands around the operator keyword.

Parameters

$outOutput
Test cases 2
Calls 1

Test cases 10§

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

Dedicated tests 4
Other tests reaching this symbol 6

Relations§

Instantiated in 1
Type checks 1