Added support for `union` statements in query builder. Closes #1146.
Added `hasConnection` method to ConnectionResolver.