GeezerVison is showing github.com — Add test case to check partition name starting by a number · phpmyadmin/sql-parser@ccb20a1
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/Components/PartitionDefinition.php +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -172,7 +172,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = |
172 | 172 | // Looking ahead for a 'VALUES' keyword. |
173 | 173 | // Loop until the end of the partition name (delimited by a whitespace) |
174 | 174 | while ($nextToken = $list->tokens[++$list->idx]) { |
175 | | - if ($nextToken->type === Token::TYPE_WHITESPACE) { |
| 175 | + if ($nextToken->type !== Token::TYPE_NONE) { |
176 | 176 | break; |
177 | 177 | } |
178 | 178 | $ret->name .= $nextToken->value; |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/Components/PartitionDefinitionTest.php +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,4 +19,16 @@ public function testParse() |
19 | 19 | $this->assertEquals('LESS THAN', $component->type); |
20 | 20 | $this->assertEquals('(1990)', $component->expr->expr); |
21 | 21 | } |
| 22 | + |
| 23 | + public function testParseNameWithUnderscore() |
| 24 | + { |
| 25 | + $component = PartitionDefinition::parse( |
| 26 | + new Parser(), |
| 27 | + $this->getTokensList('PARTITION 2017_12 VALUES LESS THAN (\'2018-01-01 00:00:00\') ENGINE = MyISAM') |
| 28 | + ); |
| 29 | + $this->assertFalse($component->isSubpartition); |
| 30 | + $this->assertEquals('2017_12', $component->name); |
| 31 | + $this->assertEquals('LESS THAN', $component->type); |
| 32 | + $this->assertEquals('(\'2018-01-01 00:00:00\')', $component->expr->expr); |
| 33 | + } |
22 | 34 | } |