classBetween
final class Between
implements Scalar
uses Snapshot
@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.
$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 $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 lower bound |
$high | Scalar | The upper bound |
$negated | bool | Whether NOT is written before BETWEEN |
Calls 8
- new Precedence line 48
- static-call Check::input() line 49
- method-call Precedence::fits() line 49
- class-const Precedence::PREDICATE() line 49
- class-const Precedence::BIT_EXPR() line 49
- method-call Precedence::admits() line 50
- method-call Precedence::absorbs() line 50
- class-const Precedence::CONJUNCTION() line 50
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the three operands, checks their widths and combines their NULL facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call Derivation::scalar() line 59
- new Operands line 62
- method-call Operands::comparable() line 63
- method-call Operands::truth() line 65
public function render(Output $out): voidWrites the operand, the optional NOT, BETWEEN and the bounds.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::node() line 73
- method-call Output::keyword() line 75
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.