Skip to content

Commit 91343d2

Browse files
committed
Merge pull request #32 from 007durgesh219/Issue#11982
Fix Row count wrong when grouping joined tables, phpmyadmin/phpmyadmin#11982
2 parents 95fc481 + 2eb3372 commit 91343d2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎src/Components/JoinKeyword.php‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class JoinKeyword extends Component
6262
* @var Condition[]
6363
*/
6464
public $on;
65+
public $using;
6566

6667
/**
6768
* @param Parser $parser The parser that serves as context.
@@ -85,10 +86,12 @@ public static function parse(Parser $parser, TokensList $list, array $options =
8586
*
8687
* 1 -----------------------[ expr ]----------------------> 2
8788
*
88-
* 2 ------------------------[ ON ]-----------------------> 3
89+
* 2 ---------------------[ ON|USING ]--------------------> 3/4
8990
*
9091
* 3 --------------------[ conditions ]-------------------> 0
9192
*
93+
* 4 ----------------------[ columns ]--------------------> 0
94+
*
9295
* @var int $state
9396
*/
9497
$state = 0;
@@ -131,14 +134,19 @@ public static function parse(Parser $parser, TokensList $list, array $options =
131134
$expr->expr = Expression::parse($parser, $list, array('field' => 'table'));
132135
$state = 2;
133136
} elseif ($state === 2) {
134-
if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'ON')) {
135-
$state = 3;
137+
if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'ON' || $token->value === 'USING')) {
138+
$state = $token->value === 'ON' ? 3 : 4;
136139
}
137140
} elseif ($state === 3) {
138141
$expr->on = Condition::parse($parser, $list);
139142
$ret[] = $expr;
140143
$expr = new JoinKeyword();
141144
$state = 0;
145+
} elseif ($state === 4) {
146+
$expr->using = ArrayObj::parse($parser, $list);
147+
$ret[] = $expr;
148+
$expr = new JoinKeyword();
149+
$state = 0;
142150
}
143151

144152
}

0 commit comments

Comments
 (0)