diff options
author | Michal Čihař <michal@cihar.com> | 2016-04-26 15:40:55 +0200 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2016-04-26 15:47:45 +0200 |
commit | 1ec169a2a76110bbd0734da23a43c4d23c1eecfb (patch) | |
tree | 78b55a222baa2c47e99a61a07cc0ae522ba94295 | |
parent | d3c22e1e82ada886a95d0ff26df999fefe01ef60 (diff) | |
download | sql-parser-1ec169a2a76110bbd0734da23a43c4d23c1eecfb.zip sql-parser-1ec169a2a76110bbd0734da23a43c4d23c1eecfb.tar.gz sql-parser-1ec169a2a76110bbd0734da23a43c4d23c1eecfb.tar.bz2 |
Allow to use function name in ASv3.4.4
Fixes https://github.com/phpmyadmin/phpmyadmin/issues/12144
Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r-- | src/Components/Expression.php | 5 | ||||
-rw-r--r-- | tests/Utils/MiscTest.php | 17 | ||||
-rw-r--r-- | tests/Utils/QueryTest.php | 8 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/Components/Expression.php b/src/Components/Expression.php index ab855f6..592207b 100644 --- a/src/Components/Expression.php +++ b/src/Components/Expression.php @@ -227,7 +227,8 @@ class Expression extends Component // beginning of a statement, so this is a subquery. $ret->subquery = $token->value; } elseif (($token->flags & Token::FLAG_KEYWORD_FUNCTION) - && (empty($options['parseField'])) + && (empty($options['parseField']) + && ! $alias) ) { $isExpr = true; } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) @@ -254,7 +255,7 @@ class Expression extends Component continue; } $isExpr = true; - } elseif ($brackets === 0 && count($ret->expr) > 0) { + } elseif ($brackets === 0 && count($ret->expr) > 0 && ! $alias) { /* End of expression */ break; } diff --git a/tests/Utils/MiscTest.php b/tests/Utils/MiscTest.php index 55b9c91..da036e0 100644 --- a/tests/Utils/MiscTest.php +++ b/tests/Utils/MiscTest.php @@ -100,7 +100,22 @@ class MiscTest extends TestCase '', null, array() - ) + ), + array( + 'SELECT * FROM orders AS ord WHERE 1', + 'db', + array( + 'db' => array( + 'alias' => null, + 'tables' => array( + 'orders' => array( + 'alias' => 'ord', + 'columns' => array(), + ) + ), + ), + ) + ), ); } } diff --git a/tests/Utils/QueryTest.php b/tests/Utils/QueryTest.php index e73696b..b3f0ab6 100644 --- a/tests/Utils/QueryTest.php +++ b/tests/Utils/QueryTest.php @@ -246,6 +246,14 @@ class QueryTest extends TestCase 'querytype' => 'SELECT' ) ), + array( + 'SELECT * FROM orders AS ord WHERE 1', + array( + 'querytype' => 'SELECT', + 'is_select' => true, + 'select_from' => true, + ) + ), ); } |