summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeven Bansod <devenbansod.bits@gmail.com>2016-09-28 10:06:27 +0530
committerDeven Bansod <devenbansod.bits@gmail.com>2016-09-28 11:02:05 +0530
commitc2d9745b21f41f673bd7c314b29ba41e90d78fd1 (patch)
treefc5fba318ee2919b2e21a68eb8fc53a669984c88
parent30b2aab917931cc45b716ec6401103400fbd5537 (diff)
downloadsql-parser-c2d9745b21f41f673bd7c314b29ba41e90d78fd1.zip
sql-parser-c2d9745b21f41f673bd7c314b29ba41e90d78fd1.tar.gz
sql-parser-c2d9745b21f41f673bd7c314b29ba41e90d78fd1.tar.bz2
Fix some errors with INTO keyword more to follow
Add more test cases Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
-rw-r--r--src/Components/IntoKeyword.php2
-rw-r--r--src/Statements/SelectStatement.php2
-rw-r--r--tests/Utils/QueryTest.php10
-rw-r--r--tests/data/parser/parseSelect9.in4
4 files changed, 11 insertions, 7 deletions
diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php
index caa3702..db29529 100644
--- a/src/Components/IntoKeyword.php
+++ b/src/Components/IntoKeyword.php
@@ -144,4 +144,4 @@ class IntoKeyword extends Component
return 'OUTFILE "' . $component->dest . '"';
}
}
-}
+} \ No newline at end of file
diff --git a/src/Statements/SelectStatement.php b/src/Statements/SelectStatement.php
index 5484f49..34a68c3 100644
--- a/src/Statements/SelectStatement.php
+++ b/src/Statements/SelectStatement.php
@@ -87,6 +87,7 @@ class SelectStatement extends Statement
'_OPTIONS' => array('_OPTIONS', 1),
// Used for selected expressions.
'_SELECT' => array('SELECT', 1),
+ 'INTO' => array('INTO', 3),
'FROM' => array('FROM', 3),
'PARTITION' => array('PARTITION', 3),
@@ -104,7 +105,6 @@ class SelectStatement extends Statement
'ORDER BY' => array('ORDER BY', 3),
'LIMIT' => array('LIMIT', 3),
'PROCEDURE' => array('PROCEDURE', 3),
- 'INTO' => array('INTO', 3),
'UNION' => array('UNION', 1),
// These are available only when `UNION` is present.
// 'ORDER BY' => array('ORDER BY', 3),
diff --git a/tests/Utils/QueryTest.php b/tests/Utils/QueryTest.php
index b3f0ab6..b5135c0 100644
--- a/tests/Utils/QueryTest.php
+++ b/tests/Utils/QueryTest.php
@@ -457,7 +457,7 @@ class QueryTest extends TestCase
);
}
- public function testRepalceClauses()
+ public function testReplaceClauses()
{
$this->assertEquals('', Query::replaceClauses(null, null, array()));
@@ -475,18 +475,18 @@ class QueryTest extends TestCase
$parser = new Parser(
'SELECT c.city_id, c.country_id ' .
+ 'INTO OUTFILE "/dev/null" ' .
'FROM `city` ' .
'WHERE city_id < 1 ' .
'ORDER BY city_id ASC ' .
- 'LIMIT 0, 1 ' .
- 'INTO OUTFILE "/dev/null"'
+ 'LIMIT 0, 1 '
);
$this->assertEquals(
'SELECT c.city_id, c.country_id ' .
+ 'INTO OUTFILE "/dev/null" ' .
'FROM city AS c ' .
'ORDER BY city_id ASC ' .
- 'LIMIT 0, 10 ' .
- 'INTO OUTFILE "/dev/null"',
+ 'LIMIT 0, 10 ',
Query::replaceClauses(
$parser->statements[0],
$parser->list,
diff --git a/tests/data/parser/parseSelect9.in b/tests/data/parser/parseSelect9.in
new file mode 100644
index 0000000..5717fe4
--- /dev/null
+++ b/tests/data/parser/parseSelect9.in
@@ -0,0 +1,4 @@
+SELECT casein_pipe, email_cp, name_first_cp, name_last_cp, purpose_pipe
+FROM (tbl_comp_person INNER JOIN `tbl_pipelist` ON tbl_comp_person.IDp = tbl_pipelist.IDp)
+WHERE casein_pipe > '2016-03-01' AND `campaign_id_pipe` = 24569 AND `weeksonlist_pipe` = 1
+ORDER BY `tbl_pipelist`.`casein_pipe` ASC \ No newline at end of file