diff options
author | Durgesh <007durgesh219@gmail.com> | 2016-02-18 19:40:32 +0530 |
---|---|---|
committer | Durgesh <007durgesh219@gmail.com> | 2016-02-18 20:14:25 +0530 |
commit | 2eb33721b00a8ee4c02bbb02819a613d153e0bc8 (patch) | |
tree | 0f50e1714b7646cf7641ee9e3cd7eeabb552207a /src | |
parent | 95fc481b8e2fc5d836479c2b62dc29e39c49df40 (diff) | |
download | sql-parser-2eb33721b00a8ee4c02bbb02819a613d153e0bc8.zip sql-parser-2eb33721b00a8ee4c02bbb02819a613d153e0bc8.tar.gz sql-parser-2eb33721b00a8ee4c02bbb02819a613d153e0bc8.tar.bz2 |
Fix Row count wrong when grouping joined tables, phpmyadmin/phpmyadmin#11982
Signed-off-by: Durgesh <007durgesh219@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Components/JoinKeyword.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Components/JoinKeyword.php b/src/Components/JoinKeyword.php index d8e6ee9..3bbb37c 100644 --- a/src/Components/JoinKeyword.php +++ b/src/Components/JoinKeyword.php @@ -62,6 +62,7 @@ class JoinKeyword extends Component * @var Condition[] */ public $on; + public $using; /** * @param Parser $parser The parser that serves as context. @@ -85,10 +86,12 @@ class JoinKeyword extends Component * * 1 -----------------------[ expr ]----------------------> 2 * - * 2 ------------------------[ ON ]-----------------------> 3 + * 2 ---------------------[ ON|USING ]--------------------> 3/4 * * 3 --------------------[ conditions ]-------------------> 0 * + * 4 ----------------------[ columns ]--------------------> 0 + * * @var int $state */ $state = 0; @@ -131,14 +134,19 @@ class JoinKeyword extends Component $expr->expr = Expression::parse($parser, $list, array('field' => 'table')); $state = 2; } elseif ($state === 2) { - if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'ON')) { - $state = 3; + if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'ON' || $token->value === 'USING')) { + $state = $token->value === 'ON' ? 3 : 4; } } elseif ($state === 3) { $expr->on = Condition::parse($parser, $list); $ret[] = $expr; $expr = new JoinKeyword(); $state = 0; + } elseif ($state === 4) { + $expr->using = ArrayObj::parse($parser, $list); + $ret[] = $expr; + $expr = new JoinKeyword(); + $state = 0; } } |