Added support for `union` statements in query builder. Closes #1146.