summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql.py
diff options
context:
space:
mode:
authorAnts Aasma <ants.aasma@gmail.com>2007-06-26 18:00:57 +0000
committerAnts Aasma <ants.aasma@gmail.com>2007-06-26 18:00:57 +0000
commit51c0d90c8d3dff721329d5ef0eb896227aff3c99 (patch)
treeb412a073db99e06374f458db8a78203e87f55956 /lib/sqlalchemy/sql.py
parentb191254d8aceca10b40dd5957f3ddf9147a4c534 (diff)
downloadsqlalchemy-51c0d90c8d3dff721329d5ef0eb896227aff3c99.tar.gz
add missing grouping for compound selects. fixes ticket #623
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r--lib/sqlalchemy/sql.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index be1ed8a69..c86fc561a 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -2427,6 +2427,8 @@ class _Grouping(ColumnElement):
return self.elem._hide_froms()
def _get_from_objects(self):
return self.elem._get_from_objects()
+ def __getattr__(self, attr):
+ return getattr(self.elem, attr)
class _Label(ColumnElement):
"""represent a label, as typically applied to any column-level element
@@ -2712,7 +2714,8 @@ class CompoundSelect(_SelectBaseMixin, FromClause):
self.is_scalar = False
self.is_subquery = False
- self.selects = selects
+ # unions group from left to right, so don't group first select
+ self.selects = [n and select.self_group(self) or select for n,select in enumerate(selects)]
# some DBs do not like ORDER BY in the inner queries of a UNION, etc.
for s in selects:
@@ -2945,6 +2948,8 @@ class Select(_SelectBaseMixin, FromClause):
self.__hide_froms.add(f)
def self_group(self, against=None):
+ if isinstance(against, CompoundSelect):
+ return self
return _Grouping(self)
def append_whereclause(self, whereclause):