classClockCall
final class ClockCall
implements Scalar
uses Snapshot
@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.
$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]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\InvalidConstructionProperties§
public Clock $clockpublic Numeral|null $precision = nullpublic OptionalWords $parentheses = OptionalWords::WrittenMethods§
public function __construct(
public Clock $clock,
public Numeral|null $precision = null,
public OptionalWords $parentheses = OptionalWords::Written,
)Parameters
$clock | Clock | The function |
$precision | Numeral|null | The fractional seconds precision, when written |
$parentheses | OptionalWords | Whether the parentheses are written when they hold no precision |
Calls 5
- class-const OptionalWords::Written() line 50
- static-call Check::input() line 52
- method-call Clock::precise() line 52
- function-call
ctype_digitline 52 - method-call Clock::bare() line 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactAnswers the current date or time, never NULL.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Clock::result() line 61
- new Temporal line 63
- class-const TemporalKind::Time() line 63
- class-const TemporalKind::DateTime() line 63
- new ScalarFact line 66
- new Known line 66
- class-const Nullability::NotNull() line 66
public function render(Output $out): voidWrites the keyword against its parentheses.
Parameters
$out | Output |
Test cases 1
Calls 3
- class-const OptionalWords::Omitted() line 74
- method-call Output::keyword() line 75
- method-call Clock::bare() line 75
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
- new SqlSemantics\Platform\MySql\Lowering\Call\TemporalRule::call() packages/sql-semantics-mysql/src/Lowering/Call/TemporalRule.php:104
- new SqlSemantics\Platform\MySql\Lowering\Call\TemporalRule::call() packages/sql-semantics-mysql/src/Lowering/Call/TemporalRule.php:107
- new SqlSemantics\Platform\MySql\Lowering\Call\TemporalRule::currentTimestamp() packages/sql-semantics-mysql/src/Lowering/Call/TemporalRule.php:146