classColumnSet
final class ColumnSet
Collects the columns of a table declaration while a definition is read; lives for one derivation.
Rule: PG-TABLE-DECLARATION-001 (work area). Columns keep the order they are added in; an inherited column of a name already present is merged into it (the column is NOT NULL when either is, and generated when either is); a column added under a name already present is not added again. Once closed, the set takes no more columns: the declaration is complete only up to that point. Status: Implemented.
Methods§
public function add(
Name $name,
TypeDescriptor $type,
bool $notNull,
bool $generated = false,
): boolAdds a column unless the set is closed or holds one of that name; answers whether it was added.
Parameters
$name | Name | |
$type | TypeDescriptor | |
$notNull | bool | |
$generated | bool | Whether the column is a generated column |
Returns
boolTest cases 7
ColumnSetTest::testAddKeepsTheFirstColumnOfANamecallsColumnSetTest::testAddKeepsTheGeneratedFlagcallsColumnSetTest::testCloseStopsAddingColumnscallsColumnSetTest::testColumnsAnswersTheColumnsInOrdercallsColumnSetTest::testInheritMergesTheGeneratedFlagcallsColumnSetTest::testInheritMergesTheNotNullFactcallsColumnSetTest::testRequireMarksAColumnNotNullcalls
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\ColumnSet::inherit() packages/sql-semantics-postgres/src/Rules/Table/Definition/ColumnSet.php:54
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:98
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::copy() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:123
public function inherit(Column $column): voidAdds an inherited column, merging it into a column of the same name.
Parameters
$column | Column |
Test cases 2
Called from 1
Calls 3
- class-const Nullability::NotNull() line 53
- method-call ColumnSet::add() line 54
- method-call ColumnSet::require() line 58
public function require(Name $name): voidMarks a column NOT NULL, when the set holds it.
Parameters
$name | Name |
Test cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\ColumnSet::inherit() packages/sql-semantics-postgres/src/Rules/Table/Definition/ColumnSet.php:58
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:99
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::constrain() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:165
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::constrain() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:169
public function close(): voidCloses the set: the columns after this point are not known.
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:95
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::copy() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:114
public function closed(): boolTells whether the set is closed.
Returns
boolTest cases 1
public function columns(): list<Column>Answers the declared columns in order.
Returns
list<Column>Test cases 6
ColumnSetTest::testAddKeepsTheGeneratedFlagcallsColumnSetTest::testCloseStopsAddingColumnscallsColumnSetTest::testColumnsAnswersTheColumnsInOrdercallsColumnSetTest::testInheritMergesTheGeneratedFlagcallsColumnSetTest::testInheritMergesTheNotNullFactcallsColumnSetTest::testRequireMarksAColumnNotNullcalls
Called from 1
Calls 3
- new Column line 100
- class-const Nullability::NotNull() line 100
- class-const Nullability::Nullable() line 100
Private surface 2§
Implementation details, listed for orientation only.
private array<string, array{Name, TypeDescriptor, bool, bool}> $entries = []private bool $closed = falseTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
ColumnSetTest::testAddKeepsTheFirstColumnOfANamecallsColumnSetTest::testAddKeepsTheGeneratedFlagcallsColumnSetTest::testClosedIsFalseForANewSetcallsColumnSetTest::testCloseStopsAddingColumnscallsColumnSetTest::testColumnsAnswersTheColumnsInOrdercallsColumnSetTest::testInheritMergesTheGeneratedFlagcallsColumnSetTest::testInheritMergesTheNotNullFactcallsColumnSetTest::testRequireMarksAColumnNotNullcalls
Relations§
Instantiated in 1
Method calls 11
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:77
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:77
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:95
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:98
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:99
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::copy() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:114
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::copy() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:121
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::copy() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:123
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::constrain() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:165
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::constrain() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:169
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:83
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:110
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:162