diff options
author | Deven Bansod <devenbansod.bits@gmail.com> | 2016-09-27 19:37:44 +0530 |
---|---|---|
committer | Deven Bansod <devenbansod.bits@gmail.com> | 2016-09-27 19:37:44 +0530 |
commit | 30b2aab917931cc45b716ec6401103400fbd5537 (patch) | |
tree | 99d5ff751467a28e2d12f117d8d3270b09cba7a2 /src/Components | |
parent | c66456f7dcc953a6246d9a5c5fa27bf0efb11a65 (diff) | |
download | sql-parser-30b2aab917931cc45b716ec6401103400fbd5537.zip sql-parser-30b2aab917931cc45b716ec6401103400fbd5537.tar.gz sql-parser-30b2aab917931cc45b716ec6401103400fbd5537.tar.bz2 |
Fix parsing of subquery in FROM clause
Fix #52
Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
Diffstat (limited to 'src/Components')
-rw-r--r-- | src/Components/JoinKeyword.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Components/JoinKeyword.php b/src/Components/JoinKeyword.php index 865246c..7062783 100644 --- a/src/Components/JoinKeyword.php +++ b/src/Components/JoinKeyword.php @@ -146,6 +146,9 @@ class JoinKeyword extends Component $state = 3; } elseif ($token->value === 'USING') { $state = 4; + } else { + /* Next clause is starting */ + break; } } } elseif ($state === 3) { @@ -182,8 +185,9 @@ class JoinKeyword extends Component foreach ($component as $c) { $ret[] = array_search($c->type, static::$JOINS) . ' ' . $c->expr . (!empty($c->on) - ? ' ON ' . Condition::build($c->on) - : ' USING ' . ArrayObj::build($c->using)); + ? ' ON ' . Condition::build($c->on) : '') + . (!empty($c->using) + ? ' USING ' . ArrayObj::build($c->using) : ''); } return implode(' ', $ret); } |