classTruthWord
final class TruthWord
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.The bare word TRUE or FALSE used as a value: a column of that name when one resolves, otherwise the integer 1 or 0.
Rule: SQLITE-TRUTH-WORD-001. TRUE and FALSE are no keywords. SQLite looks the unquoted, unqualified word up as a column first and reads it as the boolean constant only when no such column is visible. Facts: those of the column when one resolves; INTEGER and never NULL when none can; dependent when the answer depends on missing inputs. Source: https://sqlite.org/lang_expr.html#boolean_expressions. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT true AS t', []);
[$query->statement->columns[0]->expression->value, $query->field(0)->type->descriptor, $query->toString()] // => [true, \SqlSemantics\Platform\Sqlite\Statement\Type\Storage::Integer, 'SELECT TRUE AS t']Properties§
public bool $valueMethods§
public function __construct(public bool $value)Parameters
$value | bool | Whether the word is TRUE |
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactResolves the word as a column and falls back to the constant when no column of that name is visible.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 9
- method-call ColumnResolver::find() line 52
- new ColumnResolver line 52
- new Name line 52
- new ScalarFact line 54
- new Known line 54
- class-const Storage::Integer() line 54
- class-const Nullability::NotNull() line 54
- method-call ColumnFacts::of() line 57
- new ColumnFacts line 57
public function render(Output $out): voidTest cases 6§
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 4
Relations§
Instantiated in 1
Type checks 6
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\LiteralDefaults::constant() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/LiteralDefaults.php:97
- 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:158
- 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:83
- instanceof SqlSemantics\Platform\Sqlite\Rules\Resolution\ColumnFacts::denoted() packages/sql-semantics-sqlite/src/Rules/Resolution/ColumnFacts.php:75