diff options
author | Michal Čihař <michal@cihar.com> | 2017-08-30 12:07:32 +0200 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2017-08-30 12:07:32 +0200 |
commit | 6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30 (patch) | |
tree | ea2974c011912b5bec3ffadc63e54fefd7743390 | |
parent | 1c1abcc7f311eb55ddeef4fed2d03119683ccc10 (diff) | |
download | sql-parser-6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30.zip sql-parser-6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30.tar.gz sql-parser-6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30.tar.bz2 |
Add support for MariaDB 10.3 INTERSECT and EXCEPT.
Fixes #166
Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/Parser.php | 15 | ||||
-rw-r--r-- | src/Statement.php | 7 | ||||
-rw-r--r-- | src/Statements/SelectStatement.php | 2 |
4 files changed, 23 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1078114..4853319 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] * Initial support for MariaDB SQL contexts. +* Add support for MariaDB 10.3 INTERSECT and EXCEPT. ## [4.1.10] - 2017-08-21 diff --git a/src/Parser.php b/src/Parser.php index 9ef7deb..88451f0 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -110,6 +110,14 @@ class Parser extends Core 'field' => 'end_options', ), + 'INTERSECT' => array( + 'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword', + 'field' => 'union', + ), + 'EXCEPT' => array( + 'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword', + 'field' => 'union', + ), 'UNION' => array( 'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword', 'field' => 'union', @@ -427,7 +435,12 @@ class Parser extends Core continue; } - if (($token->keyword === 'UNION') || ($token->keyword === 'UNION ALL') || ($token->keyword === 'UNION DISTINCT')) { + if (($token->keyword === 'UNION') || + ($token->keyword === 'UNION ALL') || + ($token->keyword === 'UNION DISTINCT') || + ($token->keyword === 'EXCEPT') || + ($token->keyword === 'INTERSECT') + ) { $unionType = $token->keyword; continue; } diff --git a/src/Statement.php b/src/Statement.php index ab554c3..59850d6 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -246,7 +246,12 @@ abstract class Statement // Unions are parsed by the parser because they represent more than // one statement. - if (($token->value === 'UNION') || ($token->value === 'UNION ALL') || ($token->value === 'UNION DISTINCT')) { + if (($token->keyword === 'UNION') || + ($token->keyword === 'UNION ALL') || + ($token->keyword === 'UNION DISTINCT') || + ($token->keyword === 'EXCEPT') || + ($token->keyword === 'INTERSECT') + ) { break; } diff --git a/src/Statements/SelectStatement.php b/src/Statements/SelectStatement.php index deee68a..3dd0416 100644 --- a/src/Statements/SelectStatement.php +++ b/src/Statements/SelectStatement.php @@ -112,6 +112,8 @@ class SelectStatement extends Statement 'LIMIT' => array('LIMIT', 3), 'PROCEDURE' => array('PROCEDURE', 3), 'UNION' => array('UNION', 1), + 'EXCEPT' => array('EXCEPT', 1), + 'INTERSECT' => array('INTERSECT', 1), '_END_OPTIONS' => array('_END_OPTIONS', 1), // These are available only when `UNION` is present. // 'ORDER BY' => array('ORDER BY', 3), |