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

A range test: x [NOT] BETWEEN low AND high (Item_func_between).

The operand and the lower bound are bit_expr; the upper bound is a predicate, so a BETWEEN 1 AND 2 BETWEEN 3 AND 4 nests in the upper bound. A lower bound whose right edge would take the AND, such as a variable assignment, is rejected (MYSQL-PRECEDENCE-001).

Rule: MYSQL-BETWEEN-001. Facts: 1, 0 or NULL, an integer; it can be NULL when an operand can. The three operands must have the same number of columns (MYSQL-OPERAND-COLUMNS-001). Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/comparison-operators.html#operator_between. Status: Implemented.

Reading the boundsdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a BETWEEN 1 AND 9');
    [$query->statement->where->low->text, $query->statement->where->high->text] // => ['1', '9']

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 lower bound
$highScalarThe upper bound
$negatedboolWhether NOT is written before BETWEEN
Calls 8
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the three operands, checks their widths and combines their NULL facts.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the operand, the optional NOT, BETWEEN and the bounds.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 5§

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

Dedicated tests 4
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Type checks 1