final class ValueFunction
    implements Scalar, OutputNaming
    uses Snapshot
Public API: explicitly declared with @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.

Reading a precise current timestampdoctest
$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']
Rejecting a precision on CURRENT_DATEdoctest
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\InvalidConstruction

Constants§

public const MAXIMUM_PRECISION = 6

The largest fractional-seconds precision of the time types.

Properties§

public IntegerConstant|null $precision = null

Methods§

public function __construct(
    public ValueFunctionKind $kind,
    public IntegerConstant|null $precision = null,
)

Parameters

$kindValueFunctionKindThe function
$precisionIntegerConstant|nullThe fractional-seconds precision written in parentheses
Calls 2
public function outputName(): Name

Names an unaliased result column after the keyword.

Returns

Test cases 1
Calls 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact
public function render(Output $out): void

Writes the keyword and the precision.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 6§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 5
Other tests reaching this symbol 1

Relations§

Instantiated in 2