classProjection
final class Projection
Derives the output fields of a select list.
Rule: MYSQL-STAR-001. An expression item is one field named by MYSQL-SELECT-ITEM-NAME-001. * contributes the columns the FROM clause selects (MYSQL-JOIN-COLUMNS-001: merged columns once); t.* contributes every column of the tables the qualifier names, merged ones included. A relation whose columns are not all known contributes its known columns and an open star that names the missing inputs; columns whose names depend on missing inputs (MYSQL-DERIVED-SHAPES-001) are known columns. An item whose name depends on missing inputs is a field without a name that names those inputs (OutputSlot::$unnamed). A star without any table and a qualifier that names no table are reported. Terminates: one pass over the list. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html, https://dev.mysql.com/doc/refman/8.4/en/join.html. Status: Implemented.
Methods§
public function items(
list<SelectExpression|Star|TableWildcard> $items,
Derivation $derivation,
Environment $environment,
JoinedInput $from,
): list<Field|OpenStar>Derives the select list where the given environment is visible.
Parameters
$items | list<SelectExpression|Star|TableWildcard> | |
$derivation | Derivation | |
$environment | Environment | |
$from | JoinedInput |
Called from 2
Calls 10
- method-call Operands::single() line 57
- new Operands line 57
- method-call Derivation::scalar() line 57
- method-call ItemNaming::name() line 59
- new ItemNaming line 59
- new OutputSlot line 60
- new Field line 61
- function-call
countline 61 - method-call Projection::star() line 63
- method-call Projection::qualified() line 65
public function star(
list<Field|OpenStar> $fields,
Derivation $derivation,
Environment $environment,
JoinedInput $from,
): list<Field|OpenStar>Appends the columns * selects.
Parameters
$fields | list<Field|OpenStar> | |
$derivation | Derivation | |
$environment | Environment | |
$from | JoinedInput |
Called from 1
Calls 6
- method-call Derivation::report() line 81
- new Misuse line 81
- class-const MisuseRule::StarWithoutTables() line 81
- method-call Projection::expand() line 88
- method-call Projection::field() line 96
- function-call
countline 96
public function qualified(
list<Field|OpenStar> $fields,
Derivation $derivation,
Environment $environment,
QualifiedName $table,
): list<Field|OpenStar>Appends every column of the relations a qualifier names.
Parameters
$fields | list<Field|OpenStar> | |
$derivation | Derivation | |
$environment | Environment | |
$table | QualifiedName |
Called from 1
Calls 4
- method-call Projection::admits() line 112
- method-call Projection::expand() line 114
- method-call Derivation::report() line 118
- new MissingTable line 118
public function expand(
list<Field|OpenStar> $fields,
VisibleRelation $relation,
bool $merged,
): list<Field|OpenStar>Appends the columns of one relation, skipping the merged ones when asked, and an open star when its columns are not all known.
Parameters
$fields | list<Field|OpenStar> | |
$relation | VisibleRelation | |
$merged | bool |
Called from 2
public function field(int $position, VisibleRelation $relation, OutputSlot $slot): FieldAnswers the field a star selects for one column of a relation.
Parameters
$position | int | |
$relation | VisibleRelation | |
$slot | OutputSlot |
Returns
Test cases 1
Called from 2
Calls 3
- new Field line 149
- new OutputSlot line 149
- new ResolvedColumn line 149
public function admits(
Derivation $derivation,
VisibleRelation $relation,
QualifiedName $qualifier,
): boolTells whether a qualifier names a visible relation: by its correlation name when it has one, else by its table name.
Parameters
$derivation | Derivation | |
$relation | VisibleRelation | |
$qualifier | QualifiedName |
Returns
boolTest cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::deleteMultiple() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:102
- method-call SqlSemantics\Platform\MySql\Rules\Query\Projection::qualified() packages/sql-semantics-mysql/src/Rules/Query/Projection.php:112
- method-call SqlSemantics\Platform\MySql\Rules\Query\TailFacts::derive() packages/sql-semantics-mysql/src/Rules/Query/TailFacts.php:60
public function missing(list<VisibleRelation> $relations): list<MissingInput>Collects the missing inputs of open relations.
Parameters
$relations | list<VisibleRelation> |
Returns
list<MissingInput>Test cases 1
Calls 1
- function-call
array_pushline 178
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 4
- new SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::deleteMultiple() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:98
- new SqlSemantics\Platform\MySql\Rules\Query\SelectFacts::derive() packages/sql-semantics-mysql/src/Rules/Query/SelectFacts.php:67
- new SqlSemantics\Platform\MySql\Rules\Query\TailFacts::derive() packages/sql-semantics-mysql/src/Rules/Query/TailFacts.php:60
- new SqlSemantics\Platform\MySql\Statement\Dml\Evaluation::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Evaluation.php:65
Method calls 4
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::deleteMultiple() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:102
- method-call SqlSemantics\Platform\MySql\Rules\Query\SelectFacts::derive() packages/sql-semantics-mysql/src/Rules/Query/SelectFacts.php:67
- method-call SqlSemantics\Platform\MySql\Rules\Query\TailFacts::derive() packages/sql-semantics-mysql/src/Rules/Query/TailFacts.php:60
- method-call SqlSemantics\Platform\MySql\Statement\Dml\Evaluation::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Evaluation.php:65