classInsertSourceRule
final class InsertSourceRule
Lowers what INSERT and REPLACE write: the column list and the rows of VALUES or the query.
Rule: MYSQL-INSERT-SOURCE-LOWERING-001. Scope: insert_field_spec, insert_from_constructor, insert_from_subquery, insert_query_expression, insert_values, values_list, no_braces, row_value, value_or_values, fields, insert_ident, insert_columns, insert_column. A column list is ColumnList, also when it is empty; rows are InsertedRow; a query source is lowered by the query family, the 5.x forms through legacyQuery and legacyParenthesizedQuery. The answer is the column list with either the rows or the query. Terminates: lists are flattened by MYSQL-DML-LIST-001; the parts are strict subtrees. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html, https://dev.mysql.com/doc/refman/5.7/en/insert.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function source(Node $source): array{ColumnList|null, list<InsertedRow>|Query}Lowers a source with its optional column list: a node of insert_field_spec, insert_from_constructor, insert_from_subquery or insert_query_expression.
Parameters
$source | Node |
Returns
array{ColumnList|null, list<InsertedRow>|Query}Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:125
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertSourceRule::source() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertSourceRule.php:86
Calls 9
- method-call Lowering::form() line 73
- function-call
array_key_existsline 74 - class-const InsertSourceRule::LISTED() line 74
- method-call InsertSourceRule::body() line 75
- new ColumnList line 78
- method-call InsertSourceRule::columns() line 78
- function-call
countline 79 - static-call ImplementationGap::production() line 81
- method-call InsertSourceRule::source() line 86
public function body(Node $body): list<InsertedRow>|QueryLowers rows or a query without a column list: a node of insert_values or insert_query_expression (5.7).
Parameters
$body | Node |
Returns
list<InsertedRow>|QueryThrows
ImplementationGap When a production has no ruleCalled from 1
Calls 4
- method-call Lowering::form() line 102
- method-call InsertSourceRule::rows() line 105
- method-call InsertSourceRule::valued() line 106
- static-call ImplementationGap::production() line 109
public function valued(Node $keyword, Node $list): list<InsertedRow>Lowers the rows after the keyword VALUE or VALUES: a node of value_or_values and a node of values_list.
Returns
list<InsertedRow>Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 3
- method-call Lowering::form() line 121
- static-call ImplementationGap::production() line 123
- method-call InsertSourceRule::rows() line 126
public function rows(Node $list): list<InsertedRow>Lowers the rows of a node of values_list.
Parameters
$list | Node |
Returns
list<InsertedRow>Throws
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertSourceRule::body() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertSourceRule.php:105
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertSourceRule::valued() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertSourceRule.php:126
Calls 6
- method-call ListRule::items() line 138
- new ListRule line 138
- class-const InsertSourceRule::ROW_LISTS() line 138
- method-call Lowering::form() line 139
- static-call ImplementationGap::production() line 141
- new InsertedRow line 143
public function columns(Node $list): list<ColumnUse|TableWildcard>Lowers the columns of a node of fields or insert_columns.
Parameters
$list | Node |
Returns
list<ColumnUse|TableWildcard>Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 5
- method-call ListRule::items() line 158
- new ListRule line 158
- class-const InsertSourceRule::COLUMN_LISTS() line 158
- method-call Lowering::form() line 159
- static-call ImplementationGap::production() line 163
Private surface 4§
Implementation details, listed for orientation only.
private const LISTED = ['insert_field_spec: insert_values' => null, 'insert_field_spec: ( ) insert_val…private const COLUMN_LISTS = ['fields: fields , insert_ident', 'fields: insert_ident', 'insert_columns: inse…private const ROW_LISTS = ['values_list: values_list , no_braces', 'values_list: no_braces', 'values_list…private Lowering $loweringTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
InsertSourceRuleTestcalls
Relations§
Instantiated in 2
Method calls 2
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:125