classUniquePredicate
final class UniquePredicate
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.The SQL-standard test of whether a query returns no duplicate rows: UNIQUE [NULLS [NOT] DISTINCT] (SELECT …).
The grammar accepts the predicate, and the server rejects it while parsing because it does not implement it.
Rule: PG-UNIQUE-PREDICATE-001. The query is derived in the environment of the expression. Facts: the predicate is reported as not implemented, and its type is invalid. Source: https://www.postgresql.org/docs/17/features.html (feature F291), the grammar action of a_expr: UNIQUE …. Status: Implemented.
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT UNIQUE NULLS NOT DISTINCT (SELECT 1)') // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\SemanticException: UNIQUE predicate is not yet implemented.Properties§
public bool|null $nullsDistinctpublic Query $queryMethods§
public function __construct(public bool|null $nullsDistinct, public Query $query)Parameters
$nullsDistinct | bool|null | Whether NULLS DISTINCT (true) or NULLS NOT DISTINCT (false) is written, or null when neither is |
$query | Query | The query inside the parentheses |
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the query and reports the predicate.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 6
- method-call Derivation::query() line 50
- new NotImplemented line 51
- method-call Derivation::report() line 52
- new ScalarFact line 54
- new Invalid line 54
- class-const Nullability::Dependent() line 54
public function render(Output $out): voidWrites UNIQUE, the NULLS treatment and the query in parentheses.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::keyword() line 62
- method-call Output::symbol() line 66
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.