final class IntervalAddition
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @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.

Adding an interval written firstdoctest
$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 $interval
public Scalar $operand

Methods§

public function __construct(public Interval $interval, public Scalar $operand)

Parameters

$intervalIntervalThe interval added
$operandScalarThe date or time value
Calls 4
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the quantity and the operand and the temporal type of the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the interval, the plus sign and the operand.

Parameters

$outOutput
Test cases 1
Calls 1

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