classTableDeclaration
final class TableDeclaration
Derives the declaration a table definition with a column list provides.
Rule: SQLITE-TABLE-DECLARATION-001. The declaration has one column per column definition, in order, with the declared type SQLite records (SQLITE-TYPE-RECORDING-001). A TEMP table belongs to the temp schema.
NULL facts: a column is never NULL when it has a NOT NULL constraint, when it is the integer primary key (reading it yields the rowid), or when it is a primary key column of a WITHOUT ROWID or STRICT table. "Unless the column
- is an INTEGER PRIMARY KEY or the table is a WITHOUT ROWID table or a STRICT
- table or the column is declared NOT NULL, SQLite allows NULL values in a
- PRIMARY KEY column": every other column, generated columns included, can be
NULL.
Row identifier: a table that is not WITHOUT ROWID has a rowid, found by the names rowid, oid and _rowid_ unless a declared column has that name, and not part of *. When the table has an integer primary key (SQLITE-PRIMARY-KEY-001), those names denote that declared column; otherwise they denote an undeclared INTEGER column that is never NULL. A WITHOUT ROWID table has no such column.
Generated columns are ordinary columns for reading, VIRTUAL and STORED alike, and are declared generated: they cannot be written (SQLITE-GENERATED-WRITE-001). An ordinary table has no hidden columns; those exist only in virtual tables, whose columns the module decides. Terminates: one pass over the columns. Source: https://sqlite.org/lang_createtable.html, https://sqlite.org/lang_createtable.html#rowid, https://sqlite.org/withoutrowid.html, https://sqlite.org/stricttables.html, https://sqlite.org/gencol.html. Status: Implemented.
Methods§
public function domains(CreateTable $definition): list<ColumnDomain>Answers the declared type of each column, in column order.
Parameters
$definition | CreateTable |
Returns
list<ColumnDomain>Test cases 9
PrimaryKeyRuleTest::testKeyCountsEveryPrimaryKeyConstraintAndUsesTheFirstcallsPrimaryKeyRuleTest::testKeyDoesNotMakeADescendingColumnConstraintTheRowidcallsPrimaryKeyRuleTest::testKeyDoesNotMakeAnotherTypeTheRowidcallsPrimaryKeyRuleTest::testKeyIsEmptyWithoutAPrimaryKeycallsPrimaryKeyRuleTest::testKeyMakesAnIntegerPrimaryKeyColumnTheRowidcallsPrimaryKeyRuleTest::testTableKeyListsTheColumnsOfACompositeKeyInKeyOrdercallsPrimaryKeyRuleTest::testTableKeyMakesASingleIntegerColumnTheRowidWhateverItsSortOrdercallsTableDeclarationTest::testDomainsRecordTheDeclaredTypeOfEachColumncallsTableDeclarationTest::testTableBuildsTheDeclarationFromAnEstablishedKeycalls
Called from 1
Calls 3
- method-call TypeRecording::domain() line 61
- new TypeRecording line 61
- method-call CreateTable::strict() line 61
public function name(QualifiedName $written, bool $temporary): QualifiedNameAnswers the name a definition declares its object under: a TEMP object belongs to the temp schema.
Parameters
$written | QualifiedName | |
$temporary | bool |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\TableDeclaration::table() packages/sql-semantics-sqlite/src/Rules/Definition/TableDeclaration.php:90
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTableAs::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTableAs.php:69
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateView::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateView.php:93
Calls 2
- new QualifiedName line 72
- new Name line 72
public function table(
CreateTable $definition,
list<ColumnDomain> $domains,
TableKey $key,
LanguageProfile $profile,
): TableBuilds the declaration.
Parameters
$definition | CreateTable | |
$domains | list<ColumnDomain> | The declared type of each column, in column order |
$key | TableKey | |
$profile | LanguageProfile |
Returns
Test cases 1
Called from 1
Calls 9
- method-call CreateTable::withoutRowid() line 82
- method-call CreateTable::strict() line 83
- function-call
in_arrayline 86 - new Column line 87
- class-const Nullability::NotNull() line 87
- class-const Nullability::Nullable() line 87
- new Table line 90
- method-call TableDeclaration::name() line 90
- method-call TableDeclaration::rowid() line 90
public function rowid(?Column $alias): ImplicitColumnAnswers the implicit row identifier: an alias of the integer primary key column, or an undeclared INTEGER column.
Parameters
$alias | ?Column |
Returns
Called from 2
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\TableDeclaration::table() packages/sql-semantics-sqlite/src/Rules/Definition/TableDeclaration.php:90
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTableAs::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTableAs.php:72
Calls 5
- new ImplicitColumn line 98
- new Name line 99
- new Column line 100
- new ColumnDomain line 100
- class-const Nullability::NotNull() line 100
Test cases 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
TableDeclarationTest::testDomainsRecordTheDeclaredTypeOfEachColumncallsTableDeclarationTest::testNamePutsATemporaryObjectIntoTheTempSchemacallsTableDeclarationTest::testRowidAliasesTheGivenColumnOrDeclaresAnIntegerColumncallsTableDeclarationTest::testTableBuildsTheDeclarationFromAnEstablishedKeycalls
Other tests reaching this symbol 7
PrimaryKeyRuleTest::testKeyCountsEveryPrimaryKeyConstraintAndUsesTheFirstcallsPrimaryKeyRuleTest::testKeyDoesNotMakeADescendingColumnConstraintTheRowidcallsPrimaryKeyRuleTest::testKeyDoesNotMakeAnotherTypeTheRowidcallsPrimaryKeyRuleTest::testKeyIsEmptyWithoutAPrimaryKeycallsPrimaryKeyRuleTest::testKeyMakesAnIntegerPrimaryKeyColumnTheRowidcallsPrimaryKeyRuleTest::testTableKeyListsTheColumnsOfACompositeKeyInKeyOrdercallsPrimaryKeyRuleTest::testTableKeyMakesASingleIntegerColumnTheRowidWhateverItsSortOrdercalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTable::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTable.php:149
- new SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTableAs::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTableAs.php:67
- new SqlSemantics\Platform\Sqlite\Statement\Schema\CreateView::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateView.php:93
Method calls 5
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTable::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTable.php:150
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTable::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTable.php:152
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTableAs::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTableAs.php:69
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateTableAs::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateTableAs.php:72
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateView::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/CreateView.php:93