Skip to content

Commit

Permalink
Fix Row count wrong when grouping joined tables, phpmyadmin/phpmyadmi…
Browse files Browse the repository at this point in the history
…n#11982

Signed-off-by: Durgesh <007durgesh219@gmail.com>
  • Loading branch information
007durgesh219 committed Feb 18, 2016
1 parent 95fc481 commit 2eb3372
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Components/JoinKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class JoinKeyword extends Component
* @var Condition[]
*/
public $on;
public $using;

/**
* @param Parser $parser The parser that serves as context.
Expand All @@ -85,10 +86,12 @@ public static function parse(Parser $parser, TokensList $list, array $options =
*
* 1 -----------------------[ expr ]----------------------> 2
*
* 2 ------------------------[ ON ]-----------------------> 3
* 2 ---------------------[ ON|USING ]--------------------> 3/4
*
* 3 --------------------[ conditions ]-------------------> 0
*
* 4 ----------------------[ columns ]--------------------> 0
*
* @var int $state
*/
$state = 0;
Expand Down Expand Up @@ -131,14 +134,19 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$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;
}

}
Expand Down

0 comments on commit 2eb3372

Please sign in to comment.