classCollation
final class Collation
implements Scalar, OutputNaming
uses Snapshot
@visibility public.A value with an explicit collation: x COLLATE name.
Mirrors PostgreSQL's CollateClause node.
Rule: PG-COLLATE-001. Facts: the type and NULL fact of the operand; the collation is a catalog object a schema can define, so its name is not checked. A type that has no collation support makes the clause invalid. The operand must keep its place without parentheses (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-SYNTAX-COLLATE-EXPRS, https://www.postgresql.org/docs/17/collation.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT 'a' COLLATE \"C\"");
[$query->field(0)->expression->collation->last()->value, $query->toString()] // => ['C', "SELECT 'a' COLLATE \"C\""]Properties§
public Scalar $operandpublic DottedName $collationMethods§
public function __construct(public Scalar $operand, public DottedName $collation)Parameters
$operand | Scalar | The value |
$collation | DottedName | The collation name |
Calls 4
- static-call Check::input() line 50
- method-call Precedence::before() line 50
- new Precedence line 50
- class-const Precedence::COLLATE() line 50
public function outputName(): ?NameNames an unaliased result column as the operand does.
Returns
?NameTest cases 1
Calls 2
- method-call ColumnNaming::name() line 58
- new ColumnNaming line 58
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand and checks that its type has collations.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call Derivation::scalar() line 66
- new ScalarFact line 68
- method-call OperandChecks::collatable() line 68
- new OperandChecks line 68
public function render(Output $out): voidWrites the operand, COLLATE and the collation name.
Parameters
$out | Output |
Test cases 1
Calls 4
- method-call Output::node() line 76
- method-call Spelling::dotted() line 77
- new Spelling line 77
- class-const NameUse::Qualifier() line 77
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 1
Type checks 2
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnNaming::figure() packages/sql-semantics-postgres/src/Rules/Expression/ColumnNaming.php:52
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Precedence::operators() packages/sql-semantics-postgres/src/Rules/Expression/Precedence.php:219