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

A standard date and time literal: DATE 'text', TIME 'text' or TIMESTAMP 'text'.

Rule: MYSQL-TEMPORAL-LITERAL-001. Facts: DATE yields DATE, TIME yields TIME, and TIMESTAMP yields DATETIME; the fractional seconds precision of TIME and DATETIME is the number of digits written after the last decimal point, before an optional time zone offset, at most 6; never NULL. Text the server cannot read as a value of the kind is an error of the statement when it runs and is not decided here. Precision: exact for text the server accepts. Diagnostics: none. A literal spelled under another escape rule than the profile is an invalid construction. Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-literals.html, https://dev.mysql.com/doc/refman/8.4/en/fractional-seconds.html. Status: Implemented.

Reading a temporal literaldoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM t WHERE a = TIMESTAMP '2024-01-02 03:04:05.25'");
    [$query->statement->where->right->form, $query->statement->where->right->text, $query->statement->where->right->type()->precision] // => [\SqlSemantics\Platform\MySql\Statement\Literal\TemporalForm::Timestamp, '2024-01-02 03:04:05.25', '2']

Properties§

public string $text
public EscapeRule $escapes = EscapeRule::Backslash

Methods§

public function __construct(
    public TemporalForm $form,
    public string $text,
    public EscapeRule $escapes = EscapeRule::Backslash,
)

Parameters

$formTemporalFormThe keyword of the literal
$textstringThe decoded text
$escapesEscapeRuleThe rule the text is spelled under; the rule of the language profile
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the temporal type; a literal is never NULL.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the keyword and the quoted text.

Parameters

$outOutput
Calls 4

Test cases 12§

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

Dedicated tests 5
Other tests reaching this symbol 7

Relations§

Instantiated in 1