classOperators
final class Operators
Derives the result facts of the SQLite operators.
Rule: SQLITE-OPERATOR-RESULT-001. Comparisons, bitwise operators and the logical operators yield INTEGER; the IS family is never NULL; AND and OR can be NULL when an operand can; every other operator is NULL when an operand is. Addition, subtraction and multiplication yield INTEGER or REAL (integer overflow turns into REAL) and REAL when an operand is REAL. Division and remainder do the same and are NULL for a zero divisor, so they can always be NULL. Concatenation yields TEXT. -> yields the TEXT of a JSON value and ->> an INTEGER, REAL or TEXT value; both are NULL when the path selects nothing. Unary minus follows the arithmetic rule, unary plus changes nothing, ~ and NOT yield INTEGER. Source: https://sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes, https://sqlite.org/datatype3.html#operators, https://sqlite.org/json1.html#jptr. Status: Implemented.
Methods§
public function binary(
BinaryOperator $operator,
ScalarFact $left,
ScalarFact $right,
): ScalarFactAnswers the facts of a binary operation from the facts of its operands.
Parameters
$operator | BinaryOperator | |
$left | ScalarFact | |
$right | ScalarFact |
Returns
Test cases 7
OperatorsTest::testBinaryArithmeticIsIntegerOrRealUnlessAnOperandIsCertainlyRealOrNullcallsOperatorsTest::testBinaryComparisonsAndBitwiseOperatorsAreIntegerAndNullWhenAnOperandCanBecallsOperatorsTest::testBinaryConcatenationIsTextUnlessAnOperandIsNullcallsOperatorsTest::testBinaryDivisionAndRemainderCanAlwaysBeNullcallsOperatorsTest::testBinaryIsFamilyIsAnIntegerThatIsNeverNullcallsOperatorsTest::testBinaryJsonExtractionYieldsNullableTextOrAValuecallsOperatorsTest::testBinaryLogicalOperatorsAreIntegerEvenWithANullOperandcalls
Called from 1
Calls 27
- new Storages line 43
- function-call
in_arrayline 45 - class-const BinaryOperator::Is() line 45
- class-const BinaryOperator::IsNot() line 45
- class-const BinaryOperator::IsDistinctFrom() line 45
- class-const BinaryOperator::IsNotDistinctFrom() line 45
- new ScalarFact line 46
- new Known line 46
- class-const Storage::Integer() line 46
- class-const Nullability::NotNull() line 46
- class-const BinaryOperator::Extract() line 48
- method-call Storages::strict() line 49
- class-const Storage::Text() line 49
- class-const Nullability::Nullable() line 49
- class-const BinaryOperator::ExtractValue() line 51
- new NullOnly line 52
- new Choice line 52
- class-const Storage::Real() line 52
- class-const BinaryOperator::Divide() line 54
- class-const BinaryOperator::Modulo() line 54
- method-call Storages::numeric() line 55
- method-call BinaryOperator::level() line 58
- class-const Precedence::DISJUNCTION() line 59
- class-const Precedence::CONJUNCTION() line 59
- class-const Precedence::ADDITIVE() line 60
- class-const Precedence::MULTIPLICATIVE() line 60
- class-const Precedence::CONCATENATION() line 61
public function unary(UnaryOperator $operator, ScalarFact $operand): ScalarFactAnswers the facts of a prefix operation from the facts of its operand.
Parameters
$operator | UnaryOperator | |
$operand | ScalarFact |
Returns
Test cases 3
Called from 1
Calls 9
- new Storages line 71
- class-const UnaryOperator::Plus() line 74
- new ScalarFact line 74
- class-const UnaryOperator::Minus() line 75
- method-call Storages::numeric() line 75
- class-const UnaryOperator::Not() line 76
- class-const UnaryOperator::BitNot() line 76
- method-call Storages::strict() line 76
- class-const Storage::Integer() line 76
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
OperatorsTest::testBinaryArithmeticIsIntegerOrRealUnlessAnOperandIsCertainlyRealOrNullcallsOperatorsTest::testBinaryComparisonsAndBitwiseOperatorsAreIntegerAndNullWhenAnOperandCanBecallsOperatorsTest::testBinaryConcatenationIsTextUnlessAnOperandIsNullcallsOperatorsTest::testBinaryDivisionAndRemainderCanAlwaysBeNullcallsOperatorsTest::testBinaryIsFamilyIsAnIntegerThatIsNeverNullcallsOperatorsTest::testBinaryJsonExtractionYieldsNullableTextOrAValuecallsOperatorsTest::testBinaryLogicalOperatorsAreIntegerEvenWithANullOperandcallsOperatorsTest::testUnaryMinusFollowsTheArithmeticRulecallsOperatorsTest::testUnaryNotAndBitNotAreIntegerUnlessTheOperandIsNullcallsOperatorsTest::testUnaryPlusKeepsTheTypeAndTheNullabilitycalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:71
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:57
Method calls 2
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:71
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:57