final class ResultNames
Restricted visibility: declared "@visibility SqlSemantics\Platform\Sqlite". Code outside that scope must not name this declaration.

Names a result column the way SQLite does.

Rule: SQLITE-RESULT-NAME-001. An alias always names its column. Without one, SQLite keeps the span of the expression, the text from its first token to the start of the token that follows it, without the whitespace at its end, so with the comments between its tokens and after it, and names the column in one of three ways (release 3.47.2, select.c): (1) the rows a statement returns, of a SELECT or of RETURNING (sqlite3GenerateColumnNames(), short_column_names on): an expression that is a column reference, possibly in parentheses, which resolves to a column takes the name of that column as it is declared (rowid and its synonyms take the name of the integer primary key column, or rowid); any other expression is named by its span; (2) a subquery in FROM and a common table (sqlite3ExpandSubquery() and withExpand()), named before resolution: an expression that is one word, possibly qualified, in parentheses or under COLLATE, takes the word as written; any other expression is named by its span; (3) a view and a table created from a query (sqlite3ResultSetOfSelect()), named after resolution: like (1), but COLLATE and the likely(), unlikely() and likelihood() functions are looked through as well. The span is the layout the column keeps (CORE-SPELLING-001); a column built without a layout is rendered canonically and named after that rendering, which is the text the database reads. Of a compound query the leftmost arm names the columns; the expressions of a VALUES row have no span. Source: https://sqlite.org/c3ref/column_name.html, https://sqlite.org/lang_select.html. Status: Implemented.

Constants§

public const LIKELIHOOD = ['likely' => 1, 'unlikely' => 1, 'likelihood' => 2]

The functions SQLite looks through when it names a view column, by lower-case name, with their argument count.

Methods§

public function output(ResultColumn $column, Resolution|null $resolution): ?Name

Answers the name a result column has in the rows a statement returns, or null when it depends on a missing declaration.

Parameters

$columnResultColumn
$resolutionResolution|nullThe resolution of the expression, looked through parentheses

Returns

Called from 2
Calls 2
public function unnamed(ResultColumn $column, Resolution|null $resolution): list<MissingInput>

Answers the missing inputs that leave the name of a result column in the rows a statement returns undecided; empty when the name is decided or depends on nothing missing.

A word that may be a column of an undeclared table or a literal is named either after the column or after its span; a column reference takes over an undecided name of the column it resolves to.

Parameters

$columnResultColumn
$resolutionResolution|nullThe resolution of the expression, looked through parentheses

Returns

Test cases 1
Called from 1
Calls 1
public function resolved(
    ResultColumn $column,
    ColumnUse|DoubleQuotedWord|TruthWord $expression,
    ?Resolution $resolution,
): ?Name

Answers the name of a result column that is a name use from its resolution.

A column takes its declared name. A plain column name that resolves to nothing, which SQLite refuses, keeps the name as written; a double-quoted word or a truth word that resolves to nothing is a literal and is named by its span. Where the resolution is conditional on a missing declaration, so is the name of a word that may still be a literal.

Parameters

Returns

Test cases 1
Called from 2
Calls 1
public function written(?Scalar $expression): ?Name

Answers the word a result expression is written as, when it is one word: a column use, a double-quoted word or a truth word, possibly in parentheses or under COLLATE.

Parameters

$expression?Scalar

Returns

Test cases 1
Called from 2
Calls 1
public function relation(ResultColumn $column): Name

Answers the name of a result column of a subquery or common table, which SQLite gives before resolution.

Parameters

Returns

Test cases 1
Called from 1
Calls 2
public function declared(ResultColumn $column, Facts $facts): ?Name

Answers the name of a result column of a view or created table, or null when it depends on a missing declaration.

Parameters

$columnResultColumn
$factsFactsThe facts of the query, which include the expressions of the column

Returns

Called from 1
Calls 4
public function inner(Scalar $expression): ?Scalar

Answers the operand SQLite looks through when it names a view column: of parentheses, of COLLATE, and the first argument of likely(), unlikely() and likelihood(); null for any other expression.

Parameters

$expressionScalar

Returns

Test cases 1
Called from 1
Calls 3

Test cases 9§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 9

Relations§

Instantiated in 7
Method calls 14