summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2016-02-17 08:51:05 +0100
committerMichal Čihař <michal@cihar.com>2016-02-17 08:51:05 +0100
commit814e4ee572f3c7d91bcebc7767cec1d1dcd388b2 (patch)
tree4b76232a4367ccc8c15026035832423d8a1839a1
parenta027059ad141047c9a0893d7d1ee2d9bb21018c0 (diff)
downloadsql-parser-814e4ee572f3c7d91bcebc7767cec1d1dcd388b2.zip
sql-parser-814e4ee572f3c7d91bcebc7767cec1d1dcd388b2.tar.gz
sql-parser-814e4ee572f3c7d91bcebc7767cec1d1dcd388b2.tar.bz2
Change return value from getAll in case of not parsed query
Fixes https://github.com/phpmyadmin/phpmyadmin/issues/11609 Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r--src/Utils/Query.php2
-rw-r--r--tests/Utils/QueryTest.php33
2 files changed, 33 insertions, 2 deletions
diff --git a/src/Utils/Query.php b/src/Utils/Query.php
index d76e6bb..3698f1c 100644
--- a/src/Utils/Query.php
+++ b/src/Utils/Query.php
@@ -380,7 +380,7 @@ class Query
$parser = new Parser($query);
if (empty($parser->statements[0])) {
- return array();
+ return static::getFlags(null, true);
}
$statement = $parser->statements[0];
diff --git a/tests/Utils/QueryTest.php b/tests/Utils/QueryTest.php
index 8455dee..46c89ef 100644
--- a/tests/Utils/QueryTest.php
+++ b/tests/Utils/QueryTest.php
@@ -251,7 +251,38 @@ class QueryTest extends TestCase
public function testGetAll()
{
- $this->assertEquals(array(), Query::getAll(''));
+ $this->assertEquals(
+ array(
+ 'distinct' => false,
+ 'drop_database' => false,
+ 'group' => false,
+ 'having' => false,
+ 'is_affected' => false,
+ 'is_analyse' => false,
+ 'is_count' => false,
+ 'is_delete' => false,
+ 'is_explain' => false,
+ 'is_export' => false,
+ 'is_func' => false,
+ 'is_group' => false,
+ 'is_insert' => false,
+ 'is_maint' => false,
+ 'is_procedure' => false,
+ 'is_replace' => false,
+ 'is_select' => false,
+ 'is_show' => false,
+ 'is_subquery' => false,
+ 'join' => false,
+ 'limit' => false,
+ 'offset' => false,
+ 'order' => false,
+ 'querytype' => false,
+ 'reload' => false,
+ 'select_from' => false,
+ 'union' => false,
+ ),
+ Query::getAll('')
+ );
$query = 'SELECT *, actor.actor_id, sakila2.film.*
FROM sakila2.city, sakila2.film, actor';