summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2016-03-02 14:22:18 +0100
committerMichal Čihař <michal@cihar.com>2016-03-02 14:45:39 +0100
commitad0e75faa6f6943d013f23d0d1ca31b4781e7b79 (patch)
treea69f8dde727a1e44314bbbb8d813a1f47f17d96e
parent415d44d1d334f9dfca2f036890860b37dd1966fe (diff)
downloadsql-parser-ad0e75faa6f6943d013f23d0d1ca31b4781e7b79.zip
sql-parser-ad0e75faa6f6943d013f23d0d1ca31b4781e7b79.tar.gz
sql-parser-ad0e75faa6f6943d013f23d0d1ca31b4781e7b79.tar.bz2
Fixed parsing of table with DEFAULT and COMMENT.
Fixes #39 Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r--src/Components/Expression.php3
-rw-r--r--tests/Builder/CreateStatementTest.php19
2 files changed, 22 insertions, 0 deletions
diff --git a/src/Components/Expression.php b/src/Components/Expression.php
index 0b9f215..8d6471c 100644
--- a/src/Components/Expression.php
+++ b/src/Components/Expression.php
@@ -254,6 +254,9 @@ class Expression extends Component
continue;
}
$isExpr = true;
+ } elseif ($brackets === 0 && count($ret->expr) > 0) {
+ /* End of expression */
+ break;
}
}
diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php
index 2318a46..6e41d5d 100644
--- a/tests/Builder/CreateStatementTest.php
+++ b/tests/Builder/CreateStatementTest.php
@@ -42,6 +42,25 @@ class CreateStatementTest extends TestCase
);
}
+ 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();