classRowConstructor
final class RowConstructor
implements Scalar, OutputNaming
uses Snapshot
@visibility public.A row value built from fields: ROW(a, b) or (a, b).
Mirrors PostgreSQL's RowExpr node. A field written t.* expands to the columns of the relation.
Rule: PG-ROW-001. Facts: an anonymous record whose fields f1, f2, … have the types and NULL facts of the written fields, the row itself never NULL; an unaliased result column is named row. The implicit spelling needs at least two fields: one field in parentheses is a grouping. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT ROW(1, 'a')");
[count($query->field(0)->expression->fields), $query->field(0)->name->value] // => [2, 'row']new \SqlSemantics\Platform\PostgreSql\Statement\Expression\Constructor\RowConstructor([new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()], \SqlSemantics\Platform\PostgreSql\Statement\Expression\Constructor\RowSpelling::Implicit) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public list<Scalar> $fieldspublic RowSpelling $spelling = RowSpelling::ExplicitMethods§
public function __construct(
list<Scalar> $fields,
public RowSpelling $spelling = RowSpelling::Explicit,
)Parameters
$fields | list<Scalar> | The fields in order |
$spelling | RowSpelling | How the row is written |
Calls 5
- class-const RowSpelling::Explicit() line 53
- static-call Check::listOf() line 55
- class-const Scalar::class() line 55
- static-call Check::input() line 56
- function-call
countline 56
public function outputName(): NameNames an unaliased result column row.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the fields and the record they make.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 9
- method-call Derivation::scalar() line 74
- class-const Builtin::Unknown() line 75
- new Known line 75
- class-const Builtin::Text() line 75
- new OutputSlot line 76
- new Name line 76
- new ScalarFact line 79
- new Composite line 79
- class-const Nullability::NotNull() line 79
public function render(Output $out): voidWrites the fields in parentheses, after ROW when written so.
Parameters
$out | Output |
Test cases 1
Calls 3
- class-const RowSpelling::Explicit() line 87
- method-call Output::keyword() line 88
- method-call Output::symbol() line 90
Test cases 10§
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 6
ClauseRuleTest::testGroupingTermsFlattensAnImplicitRowInParenthesescallsClauseRuleTest::testGroupingTermsKeepsAnExplicitRowcallsIndirectionTest::testDeriveScalarSelectsAFieldOfARowcallsOverlapsTest::testDeriveScalarIsBooleanAndNullableWithANullFieldcallsOverlapsTest::testDeriveScalarReportsAPeriodOfOneFieldcallsOverlapsTest::testRenderWritesOverlapscalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\ConstructorRule::row() packages/sql-semantics-postgres/src/Lowering/Expression/ConstructorRule.php:52
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\ConstructorRule::row() packages/sql-semantics-postgres/src/Lowering/Expression/ConstructorRule.php:53
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\ConstructorRule::row() packages/sql-semantics-postgres/src/Lowering/Expression/ConstructorRule.php:54
Type checks 5
- instanceof SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingTerms() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:104
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Assignments::row() packages/sql-semantics-postgres/src/Rules/Manipulation/Assignments.php:184
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Assignments::types() packages/sql-semantics-postgres/src/Rules/Manipulation/Assignments.php:229
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Assignments::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/Assignments.php:259
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\GeneratedWrites::updated() packages/sql-semantics-postgres/src/Rules/Manipulation/GeneratedWrites.php:96
Type declarations 4
- type SqlSemantics\Platform\PostgreSql\Lowering\Expression\ConstructorRule packages/sql-semantics-postgres/src/Lowering/Expression/ConstructorRule.php:46
- type SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:148
- type SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Assignments packages/sql-semantics-postgres/src/Rules/Manipulation/Assignments.php:219
- type SqlSemantics\Platform\PostgreSql\Statement\Expression\Predicate\Overlaps packages/sql-semantics-postgres/src/Statement/Expression/Predicate/Overlaps.php:43