classTemporalRule
final class TemporalRule
Lowers the date and time functions with a special syntax: the clock functions, interval arithmetic, EXTRACT, GET_FORMAT, TIMESTAMPADD and TIMESTAMPDIFF.
Rule: MYSQL-CALL-TEMPORAL-001. Scope: now, func_datetime_precision, date_time_type and the alternatives of function_call_nonkeyword for CURDATE, CURTIME, NOW, SYSDATE, UTC_DATE, UTC_TIME, UTC_TIMESTAMP, DATE_ADD, DATE_SUB, ADDDATE and SUBDATE with INTERVAL, EXTRACT, GET_FORMAT, TIMESTAMPADD and TIMESTAMPDIFF. Empty parentheses after a clock function are optional and change nothing; whether they are written is kept (OptionalWords), since it is part of the text MySQL names an unaliased select list expression after; ADDDATE and SUBDATE with INTERVAL are DATE_ADD and DATE_SUB (CallNoise). Constructs: ClockCall, DateArithmetic, Extract, GetFormat, TimestampCall. Terminates: every child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function claims(string $signature): boolTells whether a production is one of this rule.
Parameters
$signature | string |
Returns
boolTest cases 1
Called from 1
Calls 3
- class-const TemporalRule::CLOCKS() line 87
- class-const TemporalRule::ARITHMETIC() line 87
- function-call
in_arrayline 87
Lowers a production this rule claims.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 2
Called from 1
Calls 17
- class-const TemporalRule::CLOCKS() line 101
- new ClockCall line 104
- method-call TemporalRule::precision() line 104
- method-call Form::node() line 104
- method-call TemporalRule::parentheses() line 104
- class-const OptionalWords::Written() line 107
- class-const OptionalWords::Omitted() line 107
- class-const TemporalRule::ARITHMETIC() line 110
- new DateArithmetic line 111
- method-call TemporalRule::currentTimestamp() line 115
- new Extract line 116
- new GetFormat line 117
- method-call TemporalRule::format() line 117
- method-call TemporalRule::timestamp() line 118
- class-const TimestampOperation::Add() line 118
- class-const TimestampOperation::Difference() line 119
- static-call ImplementationGap::production() line 120
public function timestamp(Form $form, TimestampOperation $operation): TimestampCallLowers TIMESTAMPADD or TIMESTAMPDIFF.
Parameters
$form | Form | |
$operation | TimestampOperation |
Returns
Test cases 1
Called from 2
Calls 2
- new TimestampCall line 131
- method-call Form::node() line 131
Lowers the current timestamp function: a node of now.
Parameters
$now | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 2
Called from 2
Calls 6
- method-call Lowering::form() line 141
- static-call ImplementationGap::production() line 143
- new ClockCall line 146
- class-const Clock::Now() line 146
- method-call TemporalRule::precision() line 146
- method-call TemporalRule::parentheses() line 146
public function parentheses(Node $precision): OptionalWordsAnswers whether the parentheses of an optional fractional seconds precision are written.
Parameters
$precision | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 4
- method-call Lowering::form() line 156
- class-const OptionalWords::Omitted() line 159
- class-const OptionalWords::Written() line 160
- static-call ImplementationGap::production() line 161
Lowers the optional fractional seconds precision of a clock function; empty parentheses are no precision.
Parameters
$precision | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 2
- method-call Lowering::form() line 172
- static-call ImplementationGap::production() line 177
public function format(Node $kind): TemporalFormatLowers the kind GET_FORMAT takes.
Parameters
$kind | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 3
- method-call Lowering::form() line 188
- class-const TemporalRule::FORMATS() line 190
- static-call ImplementationGap::production() line 190
Private surface 4§
Implementation details, listed for orientation only.
private const CLOCKS = ['function_call_nonkeyword: CURDATE optional_braces' => [\SqlSemantics\Platform…private const ARITHMETIC = ['function_call_nonkeyword: ADDDATE_SYM ( expr , INTERVAL_SYM expr interval )' …private const FORMATS = ['date_time_type: DATE_SYM' => \SqlSemantics\Platform\MySql\Statement\Call\Temp…private Lowering $loweringTest cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
TemporalRuleTest::testCallLowersTheTemporalSyntaxescallsTemporalRuleTest::testCallReportsAProductionOutsideTheRulecallsTemporalRuleTest::testClaimsTellsTheProductionsOfTheRulecallsTemporalRuleTest::testCurrentTimestampLowersNowcallsTemporalRuleTest::testCurrentTimestampReportsAnotherNodecallsTemporalRuleTest::testFormatLowersTheKindcallsTemporalRuleTest::testParenthesesTellsWhetherTheParenthesesAreWrittencallsTemporalRuleTest::testPrecisionTreatsEmptyParenthesesAsNoPrecisioncallsTemporalRuleTest::testTimestampLowersTheUnitAndTheOperandscalls
Relations§
Instantiated in 2
Method calls 3
- method-call SqlSemantics\Platform\MySql\Lowering\Call\CallRules::function() packages/sql-semantics-mysql/src/Lowering/Call/CallRules.php:86
- method-call SqlSemantics\Platform\MySql\Lowering\Call\CallRules::function() packages/sql-semantics-mysql/src/Lowering/Call/CallRules.php:87
- method-call SqlSemantics\Platform\MySql\Lowering\Call\CallRules::currentTimestamp() packages/sql-semantics-mysql/src/Lowering/Call/CallRules.php:107