Don't append FROM clause for replacing in UNION statements

If global statement has atleast one union, it should not have a FROM.

Fix #12619

Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
This commit is contained in:
Deven Bansod 2016-10-05 17:38:23 +05:30
parent 7d2760cec5
commit 9ceb237dd6

View File

@ -67,7 +67,9 @@ if (! empty($sql_query)) {
}
// Rebuilding the SELECT and FROM clauses.
if (count($parser->statements[0]->from) > 0) {
if (count($parser->statements[0]->from) > 0
&& count($parser->statements[0]->union) === 0
) {
$replaces = array(
array(
'FROM', 'FROM ' . SqlParser\Components\ExpressionArray::build(