classBetween
final class Between
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.A range test: an operand between a low and a high bound, optionally negated.
Rule: SQLITE-BETWEEN-001. The test is the pair of comparisons with the operand evaluated once: INTEGER, NULL when a deciding operand is NULL. The operand and the bounds are rows of one width (SQLITE-ROW-VALUE-USE-001). The operand may not end in an operator weaker than the equality group and the bounds may not start with an operator of that group or a weaker one (SQLITE-PRECEDENCE-001). Source: https://sqlite.org/lang_expr.html#the_between_operator. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT a NOT BETWEEN 1 AND 9 FROM t');
$test = $query->statement->columns[0]->expression;
[$test->negated, $test->low->digits, $test->high->digits] // => [true, '1', '9']$or = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT a OR b FROM t')->statement->columns[0]->expression;
new \SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between(new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\NullLiteral(), $or, new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\NullLiteral()) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public Scalar $operandpublic Scalar $lowpublic Scalar $highpublic bool $negated = falseMethods§
public function __construct(
public Scalar $operand,
public Scalar $low,
public Scalar $high,
public bool $negated = false,
)Parameters
$operand | Scalar | The tested expression |
$low | Scalar | The low bound |
$high | Scalar | The high bound |
$negated | bool | Whether NOT is written before BETWEEN |
Calls 6
- new Precedence line 51
- static-call Check::input() line 52
- method-call Precedence::closing() line 52
- class-const Precedence::EQUALITY() line 52
- method-call Precedence::opening() line 53
- class-const Precedence::CONJUNCTION() line 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operands and the result of the comparisons.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Derivation::scalar() line 62
- method-call RowValueUse::uniform() line 65
- new RowValueUse line 65
- new ScalarFact line 67
- method-call Storages::strict() line 67
- new Storages line 67
- class-const Storage::Integer() line 67
public function render(Output $out): voidWrites the test.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 75
- method-call Output::keyword() line 77
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
BetweenTest::testRefusesAHighBoundThatStartsWithAnEqualityOperatorcallsBetweenTest::testRefusesALowBoundThatEndsInAConjunctioncallsBetweenTest::testRefusesALowBoundThatStartsWithAnEqualityOperatorcallsBetweenTest::testRefusesATestedOperandThatEndsInAWeakerOperatorcallsBetweenTest::testRenderBindsLikeTheEqualityGroupAndGroupsToTheLeftcallsBetweenTest::testRenderWritesANewlyBuiltTestcallsBetweenTest::testRenderWritesTheNegationAndTheBoundscalls