Skip to content

Commit

Permalink
Add test case to check partition name starting by a number
Browse files Browse the repository at this point in the history
Signed-off-by: Hugues Peccatte <hugues.peccatte@aareon.fr>
  • Loading branch information
Hugues Peccatte committed Nov 1, 2019
1 parent fe98a34 commit ccb20a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Components/PartitionDefinition.php
Expand Up @@ -172,7 +172,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
// Looking ahead for a 'VALUES' keyword.
// Loop until the end of the partition name (delimited by a whitespace)
while ($nextToken = $list->tokens[++$list->idx]) {
if ($nextToken->type === Token::TYPE_WHITESPACE) {
if ($nextToken->type !== Token::TYPE_NONE) {
break;
}
$ret->name .= $nextToken->value;
Expand Down
12 changes: 12 additions & 0 deletions tests/Components/PartitionDefinitionTest.php
Expand Up @@ -19,4 +19,16 @@ public function testParse()
$this->assertEquals('LESS THAN', $component->type);
$this->assertEquals('(1990)', $component->expr->expr);
}

public function testParseNameWithUnderscore()
{
$component = PartitionDefinition::parse(
new Parser(),
$this->getTokensList('PARTITION 2017_12 VALUES LESS THAN (\'2018-01-01 00:00:00\') ENGINE = MyISAM')
);
$this->assertFalse($component->isSubpartition);
$this->assertEquals('2017_12', $component->name);
$this->assertEquals('LESS THAN', $component->type);
$this->assertEquals('(\'2018-01-01 00:00:00\')', $component->expr->expr);
}
}

0 comments on commit ccb20a1

Please sign in to comment.