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

A binary operation over two operands, in the order written.

Rule: SQLITE-BINARY-001. The facts follow SQLITE-OPERATOR-RESULT-001. A comparison takes rows of one width on both sides and every other operator takes single values (SQLITE-ROW-VALUE-USE-001). Both operands must keep their place without parentheses (SQLITE-PRECEDENCE-001): the left operand may not end in a weaker operator, the right operand may not start with an operator that is not tighter, and the right operand of IS may not be a prefix NOT, which SQLite reads as IS NOT. Source: https://sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes, https://sqlite.org/rowvalue.html. Status: Implemented.

Reading both operandsdoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 + 2');
    [$query->statement->columns[0]->expression->left->digits, $query->statement->columns[0]->expression->right->digits] // => ['1', '2']
Refusing an operand that the rendered SQL would associate differentlydoctest
$sum = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 + 2')->statement->columns[0]->expression;
    new \SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary(\SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::Multiply, $sum, new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\IntegerLiteral('3')) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public BinaryOperator $operator
public Scalar $left
public Scalar $right

Methods§

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

Parameters

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

Derives both operands and combines their facts.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the operands around the operator.

Parameters

$outOutput
Calls 5

Test cases 64§

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

Dedicated tests 6
Other tests reaching this symbol 58

Relations§

Instantiated in 5
Type checks 2