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.

Reading the bounds of a range testdoctest
$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']
Refusing a bound that the rendered SQL would associate differentlydoctest
$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\InvalidConstruction

Properties§

public Scalar $operand
public Scalar $low
public Scalar $high
public bool $negated = false

Methods§

public function __construct(
    public Scalar $operand,
    public Scalar $low,
    public Scalar $high,
    public bool $negated = false,
)

Parameters

$operandScalarThe tested expression
$lowScalarThe low bound
$highScalarThe high bound
$negatedboolWhether NOT is written before BETWEEN
Calls 6
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands and the result of the comparisons.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the test.

Parameters

$outOutput
Calls 2

Test cases 10§

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

Dedicated tests 7
Other tests reaching this symbol 3

Relations§

Instantiated in 1
Type checks 1