Added support for UNION ALL clause
Refactor implementation of nested query object in named scopes