classBinary
final class Binary
implements Scalar
uses Snapshot
@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.
$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']$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\InvalidConstructionProperties§
public BinaryOperator $operatorpublic Scalar $leftpublic Scalar $rightMethods§
public function __construct(
public BinaryOperator $operator,
public Scalar $left,
public Scalar $right,
)Parameters
$operator | BinaryOperator | The operator |
$left | Scalar | The left operand |
$right | Scalar | The right operand |
Calls 7
- new Precedence line 50
- static-call Check::input() line 51
- method-call Precedence::closing() line 51
- method-call BinaryOperator::level() line 51
- method-call Precedence::opening() line 52
- class-const BinaryOperator::Is() line 53
- class-const UnaryOperator::Not() line 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives both operands and combines their facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 9
- method-call Derivation::scalar() line 61
- new RowValueUse line 63
- method-call BinaryOperator::level() line 64
- class-const Precedence::EQUALITY() line 64
- class-const Precedence::COMPARISON() line 64
- method-call RowValueUse::uniform() line 65
- method-call RowValueUse::single() line 67
- method-call Operators::binary() line 71
- new Operators line 71
public function render(Output $out): voidWrites the operands around the operator.
Parameters
$out | Output |
Calls 5
- method-call Output::node() line 79
- method-call BinaryOperator::worded() line 80
- method-call Output::keyword() line 81
- function-call
explodeline 81 - method-call Output::symbol() line 83
Test cases 64§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
BinaryTest::testDeriveScalarRecordsTheFactsOfBothOperandscallsBinaryTest::testRefusesALeftOperandThatEndsInAWeakerOperatorcallsBinaryTest::testRefusesARightOperandThatStartsWithAnOperatorThatIsNotTightercallsBinaryTest::testRefusesIsFollowedByAPrefixNotcallsBinaryTest::testRenderKeepsTheWrittenAssociationcallsBinaryTest::testRenderWritesANewlyBuiltOperationcalls
Other tests reaching this symbol 58
CallRuleTest::testFilterLowersThePredicateOfTheFilterClausecallsExpressionRuleTest::testExpressionKeepsEveryParenthesisPairAsAGroupingcallsExpressionRuleTest::testExpressionLowersCollateCastAndRowExpressionscallsExpressionRuleTest::testWhereIsNullWithoutTheClausecallsOperatorRuleTest::testExpressionKeepsTheOperandsInWrittenOrderAndTheStructureTheParserChosecallsOperatorRuleTest::testExpressionLowersEveryBinaryOperatorByItsSpellingcallsOperatorRuleTest::testExpressionLowersTheIsFamilycallsMutationRuleTest::testUpdateLowersEveryClauseInGrammarOrdercallsTriggerRuleTest::testCreateLowersTheDeclarationAndTheProgramcallsTriggerRuleTest::testStepLowersAnInsertWithItsUpsertAndADeleteWithItsPredicatecallsTriggerRuleTest::testStepLowersAnUpdateWithEveryClausecallsTriggerRuleTest::testWhenIsNullWithoutTheClausecallsScalarTest::testDeriveScalarRecordsAFactForEveryOperandcallsPrecedenceTest::testEdgesAnswersTheLevelAndBothOperandsOfABinaryOperationcallsResultNamesTest::testSpanAnswersTheLayoutTextOrTheCanonicalRenderingcallsSelectFactsTest::testDeriveAnswersTheOutputAndRecordsEveryClausecallsSortScopesTest::testDeriveResolvesAnOrdinalAgainstTheProjectionAndReportsARowValuecallsSortScopesTest::testWordAnswersAnUnqualifiedWordOnlycallsColumnFactsTest::testOfAnswersTheFieldOfAnAliasTargetcallsBetweenTest::testRefusesAHighBoundThatStartsWithAnEqualityOperatorcallsBetweenTest::testRefusesALowBoundThatEndsInAConjunctioncallsBetweenTest::testRefusesALowBoundThatStartsWithAnEqualityOperatorcallsBetweenTest::testRefusesATestedOperandThatEndsInAWeakerOperatorcallsBetweenTest::testRenderBindsLikeTheEqualityGroupAndGroupsToTheLeftcallsNullTestTest::testRefusesAnOperandThatEndsInAWeakerOperatorcallsPatternMatchTest::testRefusesAMatchedOperandThatEndsInAWeakerOperatorcallsPatternMatchTest::testRefusesAnEscapeOperandThatStartsWithAnEqualityOperatorcallsPatternMatchTest::testRefusesAPatternThatStartsWithAnEqualityOperatorcallsUnaryTest::testRefusesAnOperandThatStartsWithAWeakerOperatorcallsUnaryTest::testRenderCoversTheTighterOperatorsThatFollowThePrefixcallsUnaryTest::testRenderWritesANewlyBuiltNegationOverASumcallsRowExpressionTest::testDeriveScalarCombinesTheNullFactsOfTheElementscallsRowExpressionTest::testDeriveScalarGivesARowOfTheWrittenWidthcallsExistsTest::testDeriveScalarDerivesTheQueryInsideTheEnvironmentOfTheExpressioncallsInListTest::testRefusesAnOperandThatEndsInAWeakerOperatorcallsInQueryTest::testRefusesAnOperandThatEndsInAWeakerOperatorcallsInTableTest::testRefusesAnOperandThatEndsInAWeakerOperatorcallsScalarSubqueryTest::testDeriveScalarDerivesTheQueryInsideTheEnvironmentOfTheExpressioncallsScalarSubqueryTest::testDeriveScalarYieldsARowValueForSeveralColumnscallsAssignmentTest::testValueSeesTheRowOfTheTargetcallsConflictTargetTest::testTermsAndPredicateSeeTheTargetTableOnlycallsDeleteTest::testDeriveWithinSeesTheTargetAndTheCommonTablesInTheWhereClausecallsUpdateTest::testDeriveWithinSeesTheTargetAndTheFromTablesInAssignmentsAndWherecallsUpsertTest::testAssignmentsAndPredicateSeeTheTableAndExcludedcallsSortTermTest::testRenderWritesTheDirectionAndTheNullPlacementcallsResultColumnTest::testRenderRefusesTheCanonicalSpellingAsALayoutcallsResultColumnTest::testRenderWritesANewlyBuiltColumncallsSelectTest::testDeriveQueryLetsWhereSeeInputColumnsBeforeAliasescallsWithQueryTest::testDeriveQueryTypesARecursiveColumnAsAnyStorageClassInTheRecursiveArmcallsJoinOnTest::testConditionSeesBothSidesOfTheJoincallsAlterAddColumnTest::testDeriveStatementDerivesTheConstraintsAgainstTheTableWithTheNewColumncallsColumnCheckTest::testDeriveConstraintResolvesColumnsOfTheTableBeingDefinedcallsColumnCheckTest::testDeriveConstraintSeesTheRowIdentifiercallsCreateIndexTest::testDeriveStatementResolvesTheTableAndTheIndexedColumnscallsCreateTableTest::testDeriveStatementBindsAQueryToTheVeryObjectsItDeclarescallsTableCheckTest::testDeriveConstraintResolvesColumnsAndTheRowIdentifiercallsCreateTriggerTest::testDeriveStatementResolvesNewAndOldToTheWatchedTablecallsVectorTest::testNameDescribesARowValueAndAMultiColumnSubquerycalls
Relations§
Instantiated in 5
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\OperatorRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/OperatorRule.php:50
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\OperatorRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/OperatorRule.php:51
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\OperatorRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/OperatorRule.php:52
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\OperatorRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/OperatorRule.php:53
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\OperatorRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/OperatorRule.php:54
Type checks 2
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ValueKinds::of() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ValueKinds.php:94
- instanceof SqlSemantics\Platform\Sqlite\Rules\Expression\Precedence::edges() packages/sql-semantics-sqlite/src/Rules/Expression/Precedence.php:112