classKeywordCall
final class KeywordCall
implements Scalar
uses Snapshot
@visibility public.A call of a built-in function whose name is a keyword and whose arguments are a plain list of expressions.
Rule: MYSQL-KEYWORD-CALL-001. The function decides the argument counts the grammar accepts and the result (MYSQL-CALL-RESULT-001); ADDDATE and SUBDATE with a number of days are typed as a date plus or minus days. GROUPING() yields 1 or 0 and is never NULL. The keyword is written against its parenthesis, and the niladic functions are written with empty parentheses, which the grammar accepts for every one of them; CURRENT_USER keeps whether its optional parentheses are written. Terminates: the arguments are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/built-in-function-reference.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT LEFT('abc', 2)");
$query->field(0)->type->descriptor->name() // => 'VARCHAR'new \SqlSemantics\Platform\MySql\Statement\Call\KeywordCall(\SqlSemantics\Platform\MySql\Statement\Call\KeywordFunction::Left, []) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstructionProperties§
public list<Scalar> $argumentspublic KeywordFunction $functionpublic OptionalWords $parentheses = OptionalWords::WrittenMethods§
public function __construct(
public KeywordFunction $function,
list<Scalar> $arguments,
public OptionalWords $parentheses = OptionalWords::Written,
)Parameters
$function | KeywordFunction | The function |
$arguments | list<Scalar> | The arguments in order |
$parentheses | OptionalWords | Whether the empty parentheses of CURRENT_USER are written; the other functions write their parentheses |
Calls 7
- class-const OptionalWords::Written() line 54
- static-call Check::listOf() line 56
- class-const Scalar::class() line 56
- method-call KeywordFunction::arity() line 57
- static-call Check::input() line 58
- function-call
countline 58 - class-const KeywordFunction::CurrentUser() line 59
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the arguments and the documented result.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 11
- method-call Arguments::one() line 69
- new Arguments line 69
- new ResultTyping line 71
- class-const KeywordFunction::AddDate() line 72
- class-const KeywordFunction::SubDate() line 72
- new ScalarFact line 73
- method-call ResultTyping::dateArithmetic() line 73
- class-const IntervalUnit::Day() line 73
- method-call ResultTyping::nullability() line 73
- method-call ResultTyping::fact() line 76
- method-call KeywordFunction::result() line 76
public function render(Output $out): voidWrites the keyword against its parenthesized arguments.
Parameters
$out | Output |
Test cases 1
Calls 3
- method-call Output::keyword() line 84
- class-const OptionalWords::Written() line 85
- method-call Output::glue() line 86
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.