classTemporalResult
final class TemporalResult
Derives the result type of date arithmetic with an interval.
Rule: MYSQL-TEMPORAL-RESULT-001. The result is a DATE when the operand is a DATE and the unit has date parts only (YEAR, QUARTER, MONTH, WEEK, DAY, YEAR_MONTH); a DATETIME when the operand is a DATETIME or TIMESTAMP, a DATE with a unit that has time parts, or a TIME with a unit that has date parts; from MySQL 8.0.28 a TIME when the operand is a TIME and the unit has time parts only, which earlier releases return as a string; and a string (VARCHAR) for every other operand, including a bare NULL. A missing or invalid operand type decides the result (MYSQL-TYPE-ALTERNATIVES-001). Terminates: no recursion. Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_date-add, https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-add. Status: Implemented.
Methods§
public function interval(
TypeFact $operand,
IntervalUnit $unit,
GrammarRelease $release,
): TypeFactAnswers the type of an operand of a type plus or minus an interval of a unit.
Parameters
$operand | TypeFact | |
$unit | IntervalUnit | |
$release | GrammarRelease |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalAddition::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalAddition.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalArithmetic::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalArithmetic.php:59
Calls 5
- new Alternatives line 56
- method-call Alternatives::blocking() line 57
- method-call Alternatives::of() line 62
- method-call TemporalResult::result() line 63
- method-call Alternatives::known() line 66
public function result(
?TypeDescriptor $type,
IntervalUnit $unit,
GrammarRelease $release,
): TypeDescriptorAnswers the result type for one operand type; null is a bare NULL.
Parameters
$type | ?TypeDescriptor | |
$unit | IntervalUnit | |
$release | GrammarRelease |
Returns
Test cases 1
Called from 1
Calls 11
- new Character line 75
- class-const CharacterKind::VarChar() line 75
- function-call
in_arrayline 77 - class-const TemporalResult::DATE_UNITS() line 77
- class-const TemporalKind::Date() line 80
- new Temporal line 80
- class-const TemporalKind::DateTime() line 80
- class-const TemporalKind::Timestamp() line 81
- class-const TemporalKind::Time() line 82
- method-call TemporalResult::time() line 82
- class-const TemporalKind::Year() line 83
public function time(IntervalUnit $unit, GrammarRelease $release): TypeDescriptorAnswers the result type for a TIME operand.
Parameters
$unit | IntervalUnit | |
$release | GrammarRelease |
Returns
Test cases 1
Called from 1
Calls 9
- function-call
in_arrayline 92 - class-const TemporalResult::TIME_UNITS() line 92
- new Temporal line 93
- class-const TemporalKind::DateTime() line 93
- class-const GrammarRelease::MySql5651() line 95
- class-const GrammarRelease::MySql5744() line 95
- new Character line 97
- class-const CharacterKind::VarChar() line 97
- class-const TemporalKind::Time() line 97
Private surface 2§
Implementation details, listed for orientation only.
private const DATE_UNITS = [\SqlSemantics\Platform\MySql\Statement\Expression\IntervalUnit::Year, \SqlSema…private const TIME_UNITS = [\SqlSemantics\Platform\MySql\Statement\Expression\IntervalUnit::Microsecond, \…Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 2
- new SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalAddition::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalAddition.php:59
- new SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalArithmetic::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalArithmetic.php:59
Method calls 2
- method-call SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalAddition::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalAddition.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalArithmetic::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalArithmetic.php:59