Skip to content

Commit

Permalink
Fixed parsing of table with DEFAULT and COMMENT.
Browse files Browse the repository at this point in the history
Fixes #39

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Mar 2, 2016
1 parent 415d44d commit ad0e75f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Components/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
continue;
}
$isExpr = true;
} elseif ($brackets === 0 && count($ret->expr) > 0) {
/* End of expression */
break;
}
}

Expand Down
19 changes: 19 additions & 0 deletions tests/Builder/CreateStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ public function testBuilderDatabase()
);
}

public function testBuilderDefaultComment()
{
$parser = new Parser(
"CREATE TABLE `wp_audio` (" .
" `somedata` int(11) DEFAULT NULL COMMENT 'ma data', " .
" `someinfo` int(11) DEFAULT NULL COMMENT 'ma info' ".
" )"
);
$stmt = $parser->statements[0];

$this->assertEquals(
"CREATE TABLE `wp_audio` (\n" .
" `somedata` int(11) DEFAULT NULL COMMENT 'ma data',\n" .
" `someinfo` int(11) DEFAULT NULL COMMENT 'ma info'\n".
") ",
$stmt->build()
);
}

public function testBuilderTable()
{
$stmt = new CreateStatement();
Expand Down

0 comments on commit ad0e75f

Please sign in to comment.