classWriteScope
final class WriteScope
Derives the parts that the data manipulation statements share: written columns, values and assignments.
Rule: MYSQL-DML-SCOPE-001. A written column is a column use resolved among the tables the statement writes; it becomes a field with the type and nullability of the column. A value is derived where the statement says; the value DEFAULT is derived where the only field of the environment is the column it is assigned to (MYSQL-DML-DEFAULT-001). Where the server requires distinct written columns (INSERT column lists and INSERT ... SET), a column resolved twice to the same column, or named twice when it does not resolve, is reported. Terminates: one pass over the finite lists. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html, https://dev.mysql.com/doc/refman/8.4/en/update.html. Status: Implemented.
Methods§
public function field(int $position, ColumnUse $column, ScalarFact $fact): FieldTurns the fact of a written column into the field the column stands for.
Parameters
$position | int | |
$column | ColumnUse | |
$fact | ScalarFact |
Returns
Test cases 1
Called from 2
Calls 2
- new Field line 45
- new OutputSlot line 45
public function value(
Scalar $value,
Field $column,
Derivation $derivation,
Environment $environment,
): ScalarFactDerives a value assigned to a column.
Parameters
$value | Scalar | |
$column | Field | |
$derivation | Derivation | |
$environment | Environment |
Returns
Called from 2
Calls 4
- method-call Derivation::scalar() line 54
- new Environment line 54
- method-call Operands::single() line 57
- new Operands line 57
public function assign(
list<Assignment> $assignments,
Derivation $derivation,
Environment $columns,
Environment $values,
bool $distinct,
): list<Field>Derives assignments: each column where the written tables are visible, each value in its environment.
Parameters
$assignments | list<Assignment> | |
$derivation | Derivation | |
$columns | Environment | |
$values | Environment | |
$distinct | bool | Whether the server requires distinct columns |
Returns
list<Field> The assigned columns in written orderCalled from 4
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::update() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:64
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::set() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:98
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::duplicates() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:195
- method-call SqlSemantics\Platform\MySql\Rules\Dml\LoadFacts::derive() packages/sql-semantics-mysql/src/Rules/Dml/LoadFacts.php:41
Calls 4
- method-call WriteScope::field() line 71
- method-call Derivation::scalar() line 71
- method-call WriteScope::value() line 72
- method-call WriteScope::distinct() line 76
public function distinct(list<Field> $fields, Derivation $derivation): voidReports each column written again.
Parameters
$fields | list<Field> | |
$derivation | Derivation |
Called from 2
Calls 3
- function-call
spl_object_idline 92 - method-call Derivation::report() line 94
- new DuplicateColumn line 94
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 6
- new SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::update() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:64
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::rows() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:67
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::set() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:98
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::open() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:141
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::duplicates() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:195
- new SqlSemantics\Platform\MySql\Rules\Dml\LoadFacts::derive() packages/sql-semantics-mysql/src/Rules/Dml/LoadFacts.php:41
Method calls 7
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::update() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:64
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::rows() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:84
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::set() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:98
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::open() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:145
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::open() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:152
- method-call SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::duplicates() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:195
- method-call SqlSemantics\Platform\MySql\Rules\Dml\LoadFacts::derive() packages/sql-semantics-mysql/src/Rules/Dml/LoadFacts.php:41