classBooleanOperation
final class BooleanOperation
implements Scalar
uses Snapshot
@visibility public.A conjunction or disjunction of two conditions: a AND b, a OR b.
Mirrors PostgreSQL's BoolExpr node of kind AND_EXPR or OR_EXPR. The parser flattens a chain into one node; the model keeps the binary structure and the groupings as written, which evaluate the same.
Rule: PG-BOOLEAN-OPERATION-001. Facts: boolean; an operand whose type is not boolean (after an unknown-typed constant takes boolean) is reported; the result can be NULL when an operand can. Both operands must keep their place without parentheses (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-logical.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT true OR false AND false');
$query->field(0)->expression->right->operator // => \SqlSemantics\Platform\PostgreSql\Statement\Expression\Operator\BooleanOperator::AndProperties§
public BooleanOperator $operatorpublic Scalar $leftpublic Scalar $rightMethods§
public function __construct(
public BooleanOperator $operator,
public Scalar $left,
public Scalar $right,
)Parameters
$operator | BooleanOperator | The operator |
$left | Scalar | The left condition |
$right | Scalar | The right condition |
Calls 7
- new Precedence line 48
- class-const BooleanOperator::And() line 49
- class-const Precedence::AND() line 49
- class-const Precedence::OR() line 49
- static-call Check::input() line 50
- method-call Precedence::before() line 50
- method-call Precedence::after() line 51
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives both conditions and checks that they are boolean.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 8
- new OperandChecks line 59
- class-const BooleanOperator::And() line 60
- method-call Derivation::scalar() line 61
- method-call OperandChecks::boolean() line 63
- new Known line 63
- class-const Builtin::Bool() line 63
- new ScalarFact line 65
- method-call OperandChecks::nullability() line 65
public function render(Output $out): voidWrites the conditions around the operator.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::node() line 73
- class-const BooleanOperator::And() line 73
Test cases 7§
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 3
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\OperatorRule::operators() packages/sql-semantics-postgres/src/Lowering/Expression/OperatorRule.php:90
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\OperatorRule::operators() packages/sql-semantics-postgres/src/Lowering/Expression/OperatorRule.php:91