classValueFunction
final class ValueFunction
implements Scalar, OutputNaming
uses Snapshot
@visibility public.A function written as a bare keyword, such as CURRENT_DATE or CURRENT_TIMESTAMP(3).
Mirrors PostgreSQL's SQLValueFunction node (and the call SYSTEM_USER becomes). Rule: PG-VALUE-FUNCTION-001. Facts: the documented type, with the precision as type modifier, reduced to 6 as the server does; NOT NULL except CURRENT_SCHEMA and SYSTEM_USER. The result column is named after the keyword in lower case. Termination: constant work. Source: https://www.postgresql.org/docs/17/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT, https://www.postgresql.org/docs/17/functions-info.html#FUNCTIONS-INFO-SESSION. Status: Implemented.
$value = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunction(
\SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunctionKind::CurrentTimestamp,
new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('3'),
);
[$value->precision->digits, $value->outputName()->value] // => ['3', 'current_timestamp']new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunction(
\SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunctionKind::CurrentDate,
new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('3'),
) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionConstants§
public const MAXIMUM_PRECISION = 6The largest fractional-seconds precision of the time types.
Properties§
public ValueFunctionKind $kindpublic IntegerConstant|null $precision = nullMethods§
public function __construct(
public ValueFunctionKind $kind,
public IntegerConstant|null $precision = null,
)Parameters
$kind | ValueFunctionKind | The function |
$precision | IntegerConstant|null | The fractional-seconds precision written in parentheses |
Calls 2
- static-call Check::input() line 61
- method-call ValueFunctionKind::precise() line 61
public function outputName(): NameNames an unaliased result column after the keyword.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the documented type and NULL fact.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 10
- method-call ValueFunctionKind::builtin() line 77
- method-call ValueFunctionKind::nullable() line 78
- class-const Nullability::Nullable() line 78
- class-const Nullability::NotNull() line 78
- new ScalarFact line 80
- new Known line 80
- method-call Numerals::within() line 83
- new Numerals line 83
- class-const ValueFunction::MAXIMUM_PRECISION() line 83
- new Parameterized line 85
public function render(Output $out): voidWrites the keyword and the precision.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::keyword() line 93
- method-call Output::glue() line 95
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
ValueFunctionTest::testDeriveScalarMakesCurrentSchemaNullablecallsValueFunctionTest::testDeriveScalarReducesThePrecisionToSixcallsValueFunctionTest::testOutputNameIsTheKeywordInLowerCasecallsValueFunctionTest::testRejectsAPrecisionOnANameFunctioncallsValueFunctionTest::testRenderWritesTheKeywordAndThePrecisioncalls
Other tests reaching this symbol 1
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\SyntaxRule::subexpression() packages/sql-semantics-postgres/src/Lowering/Invocation/SyntaxRule.php:85
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\SyntaxRule::subexpression() packages/sql-semantics-postgres/src/Lowering/Invocation/SyntaxRule.php:88