classIntervalAddition
final class IntervalAddition
implements Scalar
uses Snapshot
@visibility public.Date arithmetic with a leading interval: INTERVAL n unit + date (Item_date_add_interval).
It is a primary expression whose date operand extends to the right over every operator stronger than AND, so INTERVAL 1 DAY + a = b adds the interval to the comparison (MYSQL-PRECEDENCE-001). Only addition has this form.
Rule: MYSQL-INTERVAL-ADDITION-001. Facts: those of MYSQL-INTERVAL-ARITHMETIC-001. Terminates: the quantity and the operand are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/expressions.html#temporal-intervals. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM t WHERE INTERVAL 1 DAY + DATE '2024-01-31'");
$query->facts->scalar($query->statement->where)->type->descriptor->name() // => 'DATE'Properties§
public Interval $intervalpublic Scalar $operandMethods§
public function __construct(public Interval $interval, public Scalar $operand)Parameters
$interval | Interval | The interval added |
$operand | Scalar | The date or time value |
Calls 4
- static-call Check::input() line 47
- method-call Precedence::opening() line 47
- new Precedence line 47
- class-const Precedence::NEGATION() line 47
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the quantity and the operand and the temporal type of the result.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- new Operands line 55
- method-call Operands::single() line 56
- method-call Derivation::scalar() line 56
- new ScalarFact line 59
- method-call TemporalResult::interval() line 59
- new TemporalResult line 59
- class-const Nullability::Nullable() line 59
public function render(Output $out): voidWrites the interval, the plus sign and the operand.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::node() line 67
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 3
Relations§
Instantiated in 1
Type checks 2
- instanceof SqlSemantics\Platform\MySql\Rules\Expression\Precedence::edges() packages/sql-semantics-mysql/src/Rules/Expression/Precedence.php:197
- instanceof SqlSemantics\Platform\MySql\Statement\Expression\Operator\Arithmetic::__construct() packages/sql-semantics-mysql/src/Statement/Expression/Operator/Arithmetic.php:57