final class Treat
    implements Scalar, OutputNaming
    uses Snapshot
Public API: explicitly declared with @visibility public.

TREAT (value AS type): a conversion the server performs by calling the function named after the type.

The grammar turns TREAT(x AS t) into the call pg_catalog.t(x), where t is the last part of the type's catalog name. Rule: PG-TREAT-001. Facts: those of that call (PG-CALL-RESULT-001 with pg_catalog alone searched); the type name's modifiers are derived where they stand. The result column is named after the function. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS. Status: Implemented.

Naming the result column after the type's functiondoctest
$treat = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\Treat(
        new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral(),
        new \SqlSemantics\Platform\PostgreSql\Statement\Type\TypeName(new \SqlSemantics\Platform\PostgreSql\Statement\Type\Designation\KeywordDesignation(\SqlSemantics\Platform\PostgreSql\Statement\Type\Designation\TypeKeyword::Integer)),
    );
    $treat->outputName()->value // => 'int4'

Properties§

public Scalar $value
public TypeName $type

Methods§

public function __construct(public Scalar $value, public TypeName $type)

Parameters

$valueScalarThe value converted
$typeTypeNameThe target type
public function outputName(): Name

Names an unaliased result column after the function called.

Returns

Test cases 1
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the value, the type's modifiers and the result of the call.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 4
public function render(Output $out): void

Writes TREAT with the value and the type.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 3§

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

Dedicated tests 3

Relations§

Instantiated in 1