classTreat
final class Treat
implements Scalar, OutputNaming
uses Snapshot
@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.
$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 $valuepublic TypeName $typeMethods§
public function __construct(public Scalar $value, public TypeName $type)Parameters
$value | Scalar | The value converted |
$type | TypeName | The target type |
public function outputName(): NameNames an unaliased result column after the function called.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the value, the type's modifiers and the result of the call.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call Derivation::scalar() line 61
- method-call TypeName::deriveClause() line 62
- method-call CallTyping::catalog() line 64
- new CallTyping line 64
public function render(Output $out): voidWrites TREAT with the value and the type.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 72
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.