classDoubleQuotedWord
final class DoubleQuotedWord
implements Scalar
uses Snapshot
@visibility public.An unqualified word in double quotes used as a value: a column when one resolves, otherwise a string.
This is a different request from a column use: SQLite first looks the word up as a column name and, when no column of that name is visible, reads the word as a string literal instead of reporting an error.
Rule: SQLITE-DOUBLE-QUOTED-WORD-001. Facts: when the lookup of SQLITE-COLUMN-LOOKUP-001 finds a column or a result alias, the facts of that column; when it certainly finds nothing, TEXT and never NULL with no resolution; when the answer depends on missing inputs, a conditional resolution and a dependent type. Source: https://sqlite.org/quirks.html#dblquote. Status: Implemented.
$semantics = new \SqlSemantics\Platform\Sqlite\Semantics();
$table = $semantics->analyze('CREATE TABLE t (a INTEGER)');
$query = $semantics->analyze('SELECT "a", "b" FROM t', [$table]);
[$query->field(0)->column() === $table->declarations()[0]->columns[0], $query->field(1)->type->descriptor, $query->toString()] // => [true, \SqlSemantics\Platform\Sqlite\Statement\Type\Storage::Text, 'SELECT "a", "b" FROM t']Properties§
public Name $wordMethods§
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactResolves the word as a column and falls back to a string when no column of that name is visible.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 8
- method-call ColumnResolver::find() line 58
- new ColumnResolver line 58
- new ScalarFact line 60
- new Known line 60
- class-const Storage::Text() line 60
- class-const Nullability::NotNull() line 60
- method-call ColumnFacts::of() line 63
- new ColumnFacts line 63
public function render(Output $out): voidWrites the word in double quotes with each double quote doubled.
Parameters
$out | Output |
Calls 2
- method-call Output::spelled() line 71
- function-call
str_replaceline 71
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 6
ExpressionRuleTest::testWordLowersAnUnqualifiedWordByHowItIsWrittencallsKeyTermsTest::testColumnReadsAPlainNameAStringAndADoubleQuotedWordcallsResultNamesTest::testResolvedLeavesAWordConditionalOnAMissingDeclarationUnnamedcallsResultNamesTest::testWrittenAnswersTheOneWordAnExpressionConsistsOfcallsSortScopesTest::testWordAnswersAnUnqualifiedWordOnlycallsColumnFactsTest::testDenotedAnswersTheOutcomeOfAnUngroupedNameUsecalls
Relations§
Instantiated in 1
Type checks 14
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\Limits::nonConstant() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/Limits.php:165
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\KeyTerms::column() packages/sql-semantics-sqlite/src/Rules/Definition/KeyTerms.php:82
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\KeyTerms::reference() packages/sql-semantics-sqlite/src/Rules/Definition/KeyTerms.php:96
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ColumnTyping::text() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ColumnTyping.php:96
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::of() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:91
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::reference() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:111
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ValueKinds::of() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ValueKinds.php:100
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ValueKinds::of() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ValueKinds.php:103
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::output() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:90
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::written() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:154
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::declared() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:183
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\SortScopes::word() packages/sql-semantics-sqlite/src/Rules/Query/SortScopes.php:79
- instanceof SqlSemantics\Platform\Sqlite\Rules\Resolution\ColumnFacts::denoted() packages/sql-semantics-sqlite/src/Rules/Resolution/ColumnFacts.php:75
- instanceof SqlSemantics\Platform\Sqlite\Rules\Resolution\ColumnFacts::denoted() packages/sql-semantics-sqlite/src/Rules/Resolution/ColumnFacts.php:78