classGrouped
final class Grouped
implements Scalar, OutputNaming
uses Snapshot
@visibility public.An expression written in parentheses: ( a_expr ).
The raw parser of PostgreSQL keeps no node for the parentheses, but they fix the evaluation structure of what they enclose, so the model keeps them as written; rendering never adds or removes a grouping.
Rule: PG-GROUPED-001. The type, the NULL fact and the output name are those of the operand; the name resolution stays with the operand. A query in parentheses is a scalar subquery, and more parentheses around it belong to the query, so a grouping never encloses a scalar subquery. Source: https://www.postgresql.org/docs/17/sql-expressions.html. Status: Implemented.
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT (1 + 2) * 3')->toString() // => 'SELECT (1 + 2) * 3'Properties§
public Scalar $operandMethods§
public function __construct(public Scalar $operand)Parameters
$operand | Scalar | The enclosed expression; not a scalar subquery |
Calls 1
- static-call Check::input() line 45
public function outputName(): ?NameNames an unaliased result column as the operand does.
Returns
?NameTest cases 1
Calls 2
- method-call ColumnNaming::name() line 53
- new ColumnNaming line 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand; the grouping has its type and NULL fact.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call Derivation::scalar() line 61
- new ScalarFact line 63
public function render(Output $out): voidWrites the operand in parentheses.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::symbol() line 71
Test cases 13§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 9
ClauseRuleTest::testGroupingTermsFlattensAnImplicitRowInParenthesescallsAssignmentsTest::testBareRemovesTheParenthesescallsDistinctOrderingTest::testKeyIsTheOutputPositioncallsDistinctOrderingTest::testUnwrappedRemovesParenthesescallsOrderingTest::testBareFindsANameInParenthesescallsUnknownOutputsTest::testRawKeepsAnUntypedLiteralUnknowncallsTriggerReferencesTest::testSelectedReadsAFieldOfTheWholeRowAsAColumncallsBinaryOperationTest::testAcceptsAGroupedOperandcallsIndirectionTest::testDeriveScalarSelectsAFieldOfARowcalls
Relations§
Instantiated in 1
Type checks 13
- instanceof SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingTerms() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:100
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnNaming::figure() packages/sql-semantics-postgres/src/Rules/Expression/ColumnNaming.php:52
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::prefix() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:47
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Assignments::bare() packages/sql-semantics-postgres/src/Rules/Manipulation/Assignments.php:133
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\DistinctOrdering::unwrapped() packages/sql-semantics-postgres/src/Rules/Query/DistinctOrdering.php:136
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::bare() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:209
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Positions::value() packages/sql-semantics-postgres/src/Rules/Query/Positions.php:39
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Positions::misused() packages/sql-semantics-postgres/src/Rules/Query/Positions.php:56
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\UnknownOutputs::raw() packages/sql-semantics-postgres/src/Rules/Query/UnknownOutputs.php:36
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Command\TriggerReferences::references() packages/sql-semantics-postgres/src/Rules/Table/Command/TriggerReferences.php:91
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Command\TriggerReferences::selected() packages/sql-semantics-postgres/src/Rules/Table/Command/TriggerReferences.php:118
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Expression\Indirection::__construct() packages/sql-semantics-postgres/src/Statement/Expression/Indirection.php:63
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Table\Index\ExpressionKey::__construct() packages/sql-semantics-postgres/src/Statement/Table/Index/ExpressionKey.php:46