Skip to content

Commit 6507320

Browse files
authored
Revert "UNION scan of remainder looks too deep for parentheses (#293)" (#328)
This reverts commit fef5bc3.
1 parent f88dd20 commit 6507320

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/PHPSQLParser/processors/UnionProcessor.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,12 @@ protected function processMySQLUnion($queries) {
117117
protected function splitUnionRemainder($queries, $unionType, $outputArray)
118118
{
119119
$finalQuery = [];
120-
$firstTime = true;
121-
$finalQueryFound = false;
122-
//If this token contains a matching pair of brackets at the start and end, use it as the final query
123-
foreach ($outputArray as $key => $token) {
124-
$tokenAsArray = str_split(trim($token));
125-
$keyCount = max(array_keys($tokenAsArray));
126120

127-
if ($tokenAsArray[0] == '(' && $tokenAsArray[$keyCount] == ')' && $firstTime) {
121+
//If this token contains a matching pair of brackets at the start and end, use it as the final query
122+
$finalQueryFound = false;
123+
if (count($outputArray) === 1) {
124+
$tokenAsArray = str_split(trim($outputArray[0]));
125+
if ($tokenAsArray[0] == '(' && $tokenAsArray[count($tokenAsArray)-1] == ')') {
128126
$queries[$unionType][] = $outputArray;
129127
$finalQueryFound = true;
130128
}
@@ -139,10 +137,6 @@ protected function splitUnionRemainder($queries, $unionType, $outputArray)
139137
unset($outputArray[$key]);
140138
}
141139
}
142-
143-
if ($firstTime && !empty($token)) {
144-
$firstTime = false;
145-
}
146140
}
147141

148142

0 commit comments

Comments
 (0)