classLogical
final class Logical
implements Scalar
uses Snapshot
@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.
$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']$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\InvalidConstructionProperties§
public LogicalOperator $operatorpublic Scalar $leftpublic Scalar $rightMethods§
public function __construct(
public LogicalOperator $operator,
public Scalar $left,
public Scalar $right,
)Parameters
$operator | LogicalOperator | The operator |
$left | Scalar | The left operand |
$right | Scalar | The right operand |
Calls 5
- new Precedence line 49
- static-call Check::input() line 50
- method-call Precedence::fits() line 50
- method-call LogicalOperator::level() line 50
- method-call Precedence::opening() line 51
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives both operands and combines their NULL facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new Operands line 59
- method-call Operands::single() line 60
- method-call Derivation::scalar() line 60
- method-call Operands::truth() line 63
public function render(Output $out): voidWrites the operands around the operator keyword.
Parameters
$out | Output |
Test cases 2
Calls 1
- method-call Output::node() line 71
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
ConditionRuleTest::testExpressionBuildsTheLeftAssociationOfAChaincallsExpressionRulesTest::testExpressionLowersALogicalOperationcallsResultReferencesTest::testSelectedIsConditionalWhileAnItemWithoutADecidedNameCouldHaveTheNamecallsGroupedTest::testRenderLetsAWeakerOperandStandOnTheRightcallsNotTest::testAConjunctionOperandIsRejectedcallsIntervalAdditionTest::testAConjunctionOperandIsRejectedcalls