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

A call of a function that reads the current date or time, with its optional fractional seconds precision.

Rule: MYSQL-CLOCK-CALL-001. The result is a DATETIME, TIME or DATE with the written precision and is never NULL. A precision above 6 is the error ER_TOO_BIG_PRECISION, which the server reports when it resolves the call; the precision is kept as written. The function is written with parentheses, which are optional and change nothing (NOW alone would be a column name). Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_now, https://dev.mysql.com/doc/refman/8.4/en/fractional-seconds.html. Status: Implemented.

Typing the current timestamp with a precisiondoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT CURRENT_TIMESTAMP(3)');
    [$query->field(0)->type->descriptor->precision, $query->field(0)->nullability] // => ['3', \SqlSemantics\Platform\MySql\Model\Statement\Type\Nullability::NotNull]
Refusing a precision for a datedoctest
new \SqlSemantics\Platform\MySql\Statement\Call\ClockCall(\SqlSemantics\Platform\MySql\Statement\Call\Clock::CurrentDate, new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('3')) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public Clock $clock
public Numeral|null $precision = null
public OptionalWords $parentheses = OptionalWords::Written

Methods§

public function __construct(
    public Clock $clock,
    public Numeral|null $precision = null,
    public OptionalWords $parentheses = OptionalWords::Written,
)

Parameters

$clockClockThe function
$precisionNumeral|nullThe fractional seconds precision, when written
$parenthesesOptionalWordsWhether the parentheses are written when they hold no precision
Calls 5
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Answers the current date or time, never NULL.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the keyword against its parentheses.

Parameters

$outOutput
Test cases 1
Calls 3

Test cases 6§

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

Dedicated tests 2
Other tests reaching this symbol 4

Relations§

Instantiated in 3
Type declarations 1