classBetween
final class Between
implements Scalar
uses Snapshot
@visibility public.A range test: a [NOT] BETWEEN [SYMMETRIC] low AND high.
Mirrors PostgreSQL's A_Expr node of kind AEXPR_BETWEEN, AEXPR_NOT_BETWEEN, AEXPR_BETWEEN_SYM or AEXPR_NOT_BETWEEN_SYM. The optional ASYMMETRIC is the default and requests nothing (see the noise table). SYMMETRIC accepts the bounds in either order.
Rule: PG-BETWEEN-001. Facts: a >= low AND a <= high: the conjunction of the two comparisons (PG-OPERATOR-TYPING-001), NULL when an operand can be. The value must keep its place before BETWEEN, the low bound is a b_expr, and the high bound must keep its place (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-comparison.html#FUNCTIONS-COMPARISON-PRED-TABLE. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 2 NOT BETWEEN SYMMETRIC 3 AND 1');
[$query->field(0)->expression->negated, $query->field(0)->expression->symmetric, $query->toString()] // => [true, true, 'SELECT 2 NOT BETWEEN SYMMETRIC 3 AND 1']Properties§
public Scalar $operandpublic bool $negatedpublic bool $symmetricpublic Scalar $lowpublic Scalar $highMethods§
public function __construct(
public Scalar $operand,
public bool $negated,
public bool $symmetric,
public Scalar $low,
public Scalar $high,
)Parameters
$operand | Scalar | The tested value |
$negated | bool | Whether NOT is written |
$symmetric | bool | Whether SYMMETRIC is written |
$low | Scalar | The first bound, a `b_expr` |
$high | Scalar | The second bound |
Calls 6
- new Precedence line 55
- static-call Check::input() line 56
- method-call Precedence::before() line 56
- class-const Precedence::PATTERN() line 56
- method-call Precedence::restricted() line 57
- method-call Precedence::after() line 58
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the value and the bounds, and the comparisons of the value with them.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Derivation::scalar() line 66
- new OperatorTyping line 69
- new ScalarFact line 71
- method-call OperatorTyping::both() line 72
- method-call OperatorTyping::named() line 72
- method-call OperandChecks::nullability() line 73
- new OperandChecks line 73
public function render(Output $out): voidWrites the value, [NOT] BETWEEN [SYMMETRIC] and the bounds.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::node() line 82
- method-call Output::keyword() line 84
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.