classPrimaryKeyRule
final class PrimaryKeyRule
Finds the primary key of a table definition and whether it is the row identifier.
Rule: SQLITE-PRIMARY-KEY-001. The first PRIMARY KEY constraint in written order is the primary key; a further one is an error. A key of exactly one column whose declared type is the standard name INTEGER is an integer primary key, an alias of the rowid, with one exception that the manual documents as a quirk kept for compatibility: the column constraint INTEGER PRIMARY KEY DESC is not an alias, while the table constraint PRIMARY KEY (x DESC) is. A term of a table constraint names a key column when it is a plain name (SQLITE-KEY-TERM-001) of a declared column, compared without regard to ASCII case. Terminates: one pass over the constraints. Source: https://sqlite.org/lang_createtable.html#the_primary_key, https://sqlite.org/lang_createtable.html#rowid. Status: Implemented.
Methods§
public function key(
CreateTable $definition,
list<ColumnDomain> $domains,
Comparison $names,
): TableKeyAnswers the key of a table definition.
Parameters
$definition | CreateTable | |
$domains | list<ColumnDomain> | The declared type of each column, in column order |
$names | Comparison |
Returns
Test cases 5
PrimaryKeyRuleTest::testKeyCountsEveryPrimaryKeyConstraintAndUsesTheFirstcallsPrimaryKeyRuleTest::testKeyDoesNotMakeADescendingColumnConstraintTheRowidcallsPrimaryKeyRuleTest::testKeyDoesNotMakeAnotherTypeTheRowidcallsPrimaryKeyRuleTest::testKeyIsEmptyWithoutAPrimaryKeycallsPrimaryKeyRuleTest::testKeyMakesAnIntegerPrimaryKeyColumnTheRowidcalls
Called from 1
Calls 3
- new TableKey line 46
- class-const SortDirection::Descending() line 46
- method-call PrimaryKeyRule::tableKey() line 54
public function tableKey(
CreateTable $definition,
TablePrimaryKey $constraint,
list<ColumnDomain> $domains,
Comparison $names,
): TableKeyAnswers the key a PRIMARY KEY table constraint establishes.
Parameters
$definition | CreateTable | |
$constraint | TablePrimaryKey | |
$domains | list<ColumnDomain> | The declared type of each column, in column order |
$names | Comparison |
Returns
Test cases 2
Called from 1
Calls 5
- method-call KeyTerms::column() line 71
- new KeyTerms line 71
- method-call Comparison::equal() line 73
- function-call
countline 79 - new TableKey line 81
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
PrimaryKeyRuleTest::testKeyCountsEveryPrimaryKeyConstraintAndUsesTheFirstcallsPrimaryKeyRuleTest::testKeyDoesNotMakeADescendingColumnConstraintTheRowidcallsPrimaryKeyRuleTest::testKeyDoesNotMakeAnotherTypeTheRowidcallsPrimaryKeyRuleTest::testKeyIsEmptyWithoutAPrimaryKeycallsPrimaryKeyRuleTest::testKeyMakesAnIntegerPrimaryKeyColumnTheRowidcallsPrimaryKeyRuleTest::testTableKeyListsTheColumnsOfACompositeKeyInKeyOrdercallsPrimaryKeyRuleTest::testTableKeyMakesASingleIntegerColumnTheRowidWhateverItsSortOrdercalls