classKeyTerms
final class KeyTerms
Reads the column a term of a PRIMARY KEY or UNIQUE table constraint names.
Rule: SQLITE-KEY-TERM-001. The grammar writes key terms as expressions. SQLite looks through parentheses and COLLATE and takes the term as a key column when what remains is a plain name, written as an identifier, as a double-quoted word or as a string literal (LiteralColumn: a string under any number of COLLATE clauses in a key constraint, under at most one in an index term, is read as an identifier; the structure must write it as a LiteralColumn, so a plain string there is refused at construction). A qualified column reference is still a column for the index of the constraint, but it does not mark the column as part of the primary key; anything else is "expressions prohibited in PRIMARY KEY and UNIQUE
- constraints". Terminates: each step removes one wrapper of a finite
expression. Source: https://sqlite.org/lang_createtable.html#the_primary_key (and sqlite3AddPrimaryKey(), sqlite3StringToId() and sqlite3CreateIndex() in build.c of the release). Status: Implemented.
Methods§
Answers the expression of a term without its parentheses and collations.
Parameters
$term | Scalar |
Returns
Test cases 1
Called from 2
Answers the expression of a term without its parentheses and at most the given number of collations; null admits any number.
Parameters
$term | Scalar | |
$collations | ?int |
Returns
Test cases 1
public function string(Scalar $term, ?int $collations): boolTells whether a term is a string literal SQLite would read as a column name, which the structure must write as a LiteralColumn.
Parameters
$term | Scalar | |
$collations | ?int |
Returns
boolTest cases 1
Called from 4
- method-call SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::term() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:63
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateIndex::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/CreateIndex.php:86
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:58
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:53
Calls 1
- method-call KeyTerms::beneath() line 70
Answers the name of the key column a term denotes, or null when the term is not a plain name.
Parameters
$term | Scalar |
Returns
?NameTest cases 2
Called from 1
Calls 1
- method-call KeyTerms::core() line 78
public function reference(Scalar $term): boolTells whether a term is a column reference of any form, which a key constraint accepts.
Parameters
$term | Scalar |
Returns
boolCalled from 2
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::deriveConstraint() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:69
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::deriveConstraint() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:64
Calls 1
- method-call KeyTerms::core() line 94
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
KeyTermsTest::testBeneathStopsAtTheCollationLimitcallsKeyTermsTest::testColumnIsNullForAQualifiedReferenceAndForAnExpressioncallsKeyTermsTest::testColumnReadsAPlainNameAStringAndADoubleQuotedWordcallsKeyTermsTest::testCoreLooksThroughParenthesesAndCollationscallsKeyTermsTest::testReferenceAcceptsEveryColumnReferenceAndNoOtherExpressioncallsKeyTermsTest::testStringTellsALiteralUnderTheAdmittedWrapperscalls
Relations§
Instantiated in 7
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::term() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:63
- new SqlSemantics\Platform\Sqlite\Rules\Definition\PrimaryKeyRule::tableKey() packages/sql-semantics-sqlite/src/Rules/Definition/PrimaryKeyRule.php:71
- new SqlSemantics\Platform\Sqlite\Statement\Schema\CreateIndex::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/CreateIndex.php:86
- new SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:58
- new SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::deriveConstraint() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:69
- new SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:53
- new SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::deriveConstraint() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:64
Method calls 7
- method-call SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::term() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:63
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\PrimaryKeyRule::tableKey() packages/sql-semantics-sqlite/src/Rules/Definition/PrimaryKeyRule.php:71
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\CreateIndex::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/CreateIndex.php:86
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:58
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::deriveConstraint() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:69
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:53
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::deriveConstraint() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:64