[4.0] Fix unioning more than 1 query

Allows more than 1 union() or unionAll() per query.