classWord
final class Word
implements Node
uses Snapshot
@visibility public.A word at a position where SQLite looks at the written text: the name and how it is quoted.
At most positions a quoted and an unquoted spelling of a name mean the same. At a few they do not: SQLite records a declared column type with its quotes, accepts the table options and the storage word of a generated column only without quotes, and reads an unquoted TRUE or FALSE default as a number. A word keeps the quoting so that those meanings survive.
Rule: SQLITE-WORD-001. The spelling is the name between its delimiters with each embedded closing delimiter doubled; a bracketed word cannot contain ]. Source: https://sqlite.org/lang_keywords.html. Status: Implemented.
$word = new \SqlSemantics\Platform\Sqlite\Statement\Lexical\Word(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('big "int"'), \SqlSemantics\Platform\Sqlite\Statement\Lexical\WordQuote::Double);
$word->spelling() // => '"big ""int"""'new \SqlSemantics\Platform\Sqlite\Statement\Lexical\Word(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('select')) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Lexical\Word(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('two words')) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Lexical\Word(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('a]b'), \SqlSemantics\Platform\Sqlite\Statement\Lexical\WordQuote::Bracket) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public Name $namepublic WordQuote $quote = WordQuote::BareMethods§
Calls 6
- class-const WordQuote::Bare() line 46
- static-call Check::input() line 48
- method-call BareWords::usable() line 48
- new BareWords line 48
- class-const WordQuote::Bracket() line 49
- function-call
str_containsline 49
public function bare(): boolTells whether the word is written without quotes.
Returns
boolTest cases 1
Called from 1
Calls 1
- class-const WordQuote::Bare() line 57
public function is(string $keyword): boolTells whether the unquoted word equals a keyword, compared without regard to ASCII case as SQLite compares it.
Parameters
$keyword | string |
Returns
boolTest cases 2
Called from 4
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Column\DefaultWord::truth() packages/sql-semantics-sqlite/src/Statement/Schema/Column/DefaultWord.php:50
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Column\DefaultWord::truth() packages/sql-semantics-sqlite/src/Statement/Schema/Column/DefaultWord.php:54
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableOption::kind() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableOption.php:44
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableOption::kind() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableOption.php:47
Calls 2
- method-call Word::bare() line 65
- function-call
strcasecmpline 65
public function spelling(): stringAnswers the exact text of the word as SQLite reads it.
Returns
stringTest cases 2
Called from 2
- method-call SqlSemantics\Platform\Sqlite\Statement\Lexical\Word::render() packages/sql-semantics-sqlite/src/Statement/Lexical/Word.php:87
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Problem\UnknownStorage::message() packages/sql-semantics-sqlite/src/Statement/Schema/Problem/UnknownStorage.php:38
Calls 6
- class-const WordQuote::Bare() line 74
- class-const WordQuote::Single() line 75
- function-call
str_replaceline 75 - class-const WordQuote::Double() line 76
- class-const WordQuote::Backtick() line 77
- class-const WordQuote::Bracket() line 78
public function render(Output $out): voidWrites the word with its own quoting.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::spelled() line 87
- method-call Word::spelling() line 87
Test cases 33§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
WordTest::testBareTellsAnUnquotedWordFromAQuotedOnecallsWordTest::testIsComparesAnUnquotedWordWithoutRegardToCasecallsWordTest::testIsNeverMatchesAQuotedWordcallsWordTest::testRenderWritesTheWordWithItsOwnQuotingcallsWordTest::testSpellingAcceptsAKeywordTheGrammarLetsFallBackToAnIdentifiercallsWordTest::testSpellingDoublesTheEmbeddedClosingDelimitercalls
Other tests reaching this symbol 27
TypeNameRuleTest::testNamedKeepsTheWordsOfATypeNameInWrittenOrdercallsTypeNameRuleTest::testWordsKeepTheQuotingOfEachWordcallsTypeRecordingTest::testDomainDropsTheGeneratedAlwaysKeywordsTheParserReadsAsTypeWordscallsTypeRecordingTest::testDomainKeepsOnlyTheFirstQuotedRunOfATextThatStartsWithAQuotecallsTypeRecordingTest::testDomainKeepsTheQuotesOfAWordThatIsNotFirstcallsTypeRecordingTest::testDomainMarksAColumnOfAStrictTablecallsTypeRecordingTest::testDomainRecognizesAStandardTypeAlsoWhenItIsOneQuotedWordcallsTypeRecordingTest::testDomainRecordsTheWrittenTextWithItsArgumentscallsDefaultWordTest::testTruthIsNullForATextDefaultcallsDefaultWordTest::testTruthReadsAnUnquotedTrueOrFalsecallsGeneratedTest::testStorageIsNullForAnyOtherWordAndForAQuotedWordcallsGeneratedTest::testStorageIsVirtualUnlessStoredIsWrittencallsCreateTableTest::testWithoutRowidAndStrictReadTheKnownOptionscallsUnknownStorageTest::testMessageSpellsTheWordAsWrittencallsUnknownTableOptionTest::testMessageSpellsTheWordAsWrittencallsTableOptionTest::testKindIsNullForEveryOtherWordAndForAQuotedWordcallsTableOptionTest::testKindReadsTheTwoKnownOptionsWithoutRegardToCasecallsTableOptionTest::testRenderWritesTheWordWithItsQuotingcallsSignedNumberTest::testRenderWritesANewlyBuiltNumbercallsTypeNameTest::testAffinityFollowsTheOrderedSubstringRulescallsTypeNameTest::testAffinityIgnoresTheCaseAndTheArgumentscallsTypeNameTest::testAffinityOfAQuotedFirstWordUsesThatWordOnlycallsTypeNameTest::testAffinityReadsTheWholeTextSoFloatingPointIsIntegercallsTypeNameTest::testRefusesMoreThanTwoArgumentscallsTypeNameTest::testTextJoinsBareWordsWithOneSpacecallsTypeNameTest::testTextKeepsOnlyTheFirstWordWhenItIsQuotedcallsTypeNameTest::testTextKeepsTheQuotesOfAWordThatIsNotFirstcalls
Relations§
Instantiated in 2
Method calls 5
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Column\DefaultWord::truth() packages/sql-semantics-sqlite/src/Statement/Schema/Column/DefaultWord.php:50
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Column\DefaultWord::truth() packages/sql-semantics-sqlite/src/Statement/Schema/Column/DefaultWord.php:54
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Problem\UnknownStorage::message() packages/sql-semantics-sqlite/src/Statement/Schema/Problem/UnknownStorage.php:38
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableOption::kind() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableOption.php:44
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableOption::kind() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableOption.php:47
Constant reads 1
Type declarations 6
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\WordRule packages/sql-semantics-sqlite/src/Lowering/Definition/WordRule.php:42
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\WordRule packages/sql-semantics-sqlite/src/Lowering/Definition/WordRule.php:52
- type SqlSemantics\Platform\Sqlite\Statement\Schema\Column\DefaultWord packages/sql-semantics-sqlite/src/Statement/Schema/Column/DefaultWord.php:40
- type SqlSemantics\Platform\Sqlite\Statement\Schema\Column\Generated packages/sql-semantics-sqlite/src/Statement/Schema/Column/Generated.php:50
- type SqlSemantics\Platform\Sqlite\Statement\Schema\Problem\UnknownStorage packages/sql-semantics-sqlite/src/Statement/Schema/Problem/UnknownStorage.php:29
- type SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableOption packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableOption.php:34