classCreateCast
final class CreateCast
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A request to define a cast between two types.
Rule: PG-CAST-001. Mirrors CreateCastStmt: source and target type, the function (or binary coercion, or I/O conversion) and the CoercionContext; no context means the cast is explicit only. The types and the function are looked up when the cast is created, so the statement records no facts beyond the type names. Source: https://www.postgresql.org/docs/17/sql-createcast.html. Status: Implemented.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE CAST (int4 AS myint) WITHOUT FUNCTION AS IMPLICIT');
[$operation->statement->method, $operation->statement->context] // => [\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Cast\CastConversion::Binary, \SqlSemantics\Platform\PostgreSql\Statement\Catalog\Cast\CastContext::Implicit]Properties§
public TypeName $sourcepublic TypeName $targetpublic ObjectReference|CastConversion $methodpublic CastContext|null $context = nullMethods§
public function __construct(
public TypeName $source,
public TypeName $target,
public ObjectReference|CastConversion $method,
public CastContext|null $context = null,
)Parameters
$source | TypeName | The source type |
$target | TypeName | The target type |
$method | ObjectReference|CastConversion | The function, or how the cast converts without one |
$context | CastContext|null | Where the cast applies unwritten; null for explicit casts only |
public function deriveStatement(Derivation $derivation): voidDerives the type names and the function signature.
Parameters
$derivation | Derivation |
Calls 2
- method-call ClauseFacts::derive() line 48
- new ClauseFacts line 48
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 56
- method-call Output::node() line 58
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CreateCastTestcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Lowering\Catalog\CastRule::statement() packages/sql-semantics-postgres/src/Lowering/Catalog/CastRule.php:69
- new SqlSemantics\Platform\PostgreSql\Lowering\Catalog\CastRule::statement() packages/sql-semantics-postgres/src/Lowering/Catalog/CastRule.php:70
- new SqlSemantics\Platform\PostgreSql\Lowering\Catalog\CastRule::statement() packages/sql-semantics-postgres/src/Lowering/Catalog/CastRule.php:71