classKeyPartRule
final class KeyPartRule
Lowers the key part lists of indexes and foreign keys.
Rule: MYSQL-KEY-PART-001. Scope: key_list, key_part, key_list_with_expression, key_part_with_expression. In MySQL 5.x the sort direction follows the key part in the list production; in 8.0 it belongs to the key part. A prefix length is kept as written. Constructs: ColumnPart, ExpressionPart. Terminates: lists are flattened iteratively. Source: https://dev.mysql.com/doc/refman/8.4/en/create-index.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a key part list: a node of key_list or key_list_with_expression.
Parameters
$list | Node |
Returns
non-empty-list<KeyPart>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 4
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\IndexRule::index() packages/sql-semantics-mysql/src/Lowering/TableDefinition/IndexRule.php:74
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::columns() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:86
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::index() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:116
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::constrained() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:141
Calls 5
- method-call Spine::items() line 57
- new Spine line 57
- class-const KeyPartRule::LISTS() line 57
- static-call Check::invariant() line 59
- method-call KeyPartRule::part() line 60
public function columns(Node $list): non-empty-list<ColumnPart>Lowers the columns of a foreign key: a node of key_list.
Parameters
$list | Node |
Returns
non-empty-list<ColumnPart>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 2
- method-call KeyPartRule::parts() line 86
- static-call Check::invariant() line 87
Lowers one key part: a node of key_part or key_part_with_expression, with the direction the 5.x list writes after it.
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 4
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::parts() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:60
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::parts() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:64
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::parts() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:70
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::part() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:106
Calls 5
- method-call KeyPartRule::part() line 106
- new ExpressionPart line 107
- new ColumnPart line 108
- method-call KeyPartRule::length() line 109
- static-call ImplementationGap::production() line 112
Lowers the prefix length of a key part: the number token at the third position.
Parameters
$part | Node |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::part() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:109
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyPartRule::part() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyPartRule.php:111
Private surface 2§
Implementation details, listed for orientation only.
private const LISTS = ['key_list: key_list , key_part order_dir', 'key_list: key_part order_dir', 'ke…private Lowering $loweringTest cases 4§
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\Lowering\TableDefinition\IndexRule::index() packages/sql-semantics-mysql/src/Lowering/TableDefinition/IndexRule.php:74
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::element() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:70
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::index() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:116
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::constrained() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:141
Method calls 4
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\IndexRule::index() packages/sql-semantics-mysql/src/Lowering/TableDefinition/IndexRule.php:74
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::element() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:76
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::index() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:116
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\KeyRule::constrained() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/KeyRule.php:141