]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
more tweak to compoundselect parenthesizing/subquery flag
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Mar 2006 01:17:12 +0000 (01:17 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Mar 2006 01:17:12 +0000 (01:17 +0000)
lib/sqlalchemy/ansisql.py
lib/sqlalchemy/sql.py

index 7b39d5358e2529ba8b0bc1420a10f259471585c0..64715cb4f16d4a96b403b82664d9632806261d1f 100644 (file)
@@ -186,7 +186,7 @@ class ANSICompiler(sql.Compiled):
             # if we are within a visit to a Select, set up the "typemap"
             # for this column which is used to translate result set values
             self.typemap.setdefault(column.key.lower(), column.type)
-        if column.table is not None and column.table.name is None:
+        if column.table is None or column.table.name is None:
             self.strings[column] = column.name
         else:
             self.strings[column] = "%s.%s" % (column.table.name, column.name)
@@ -368,7 +368,7 @@ class ANSICompiler(sql.Compiled):
                 
         text += self.visit_select_postclauses(select)
  
-        if getattr(select, 'issubquery', False):
+        if getattr(select, 'useparens', False):
             self.strings[select] = "(" + text + ")"
         else:
             self.strings[select] = text
index 5389f4bd7223830a5ec23d2c2b8175e6317219df..d4d059d6a730e4ad806f9e345153c55ff0b1b4d9 100644 (file)
@@ -1208,11 +1208,8 @@ class Select(SelectBaseMixin, FromClause):
             self.is_where = is_where
         def visit_compound_select(self, cs):
             self.visit_select(cs)
-            # unselect the 'issubquery' flag on the selects within the compound,
-            # i.e. "SELECT foo UNION SELECT bar", since the enclosing compound select
-            # is the "subquery"
             for s in cs.selects:
-                s.issubquery = False
+                s.useparens = False
         def visit_column(self, c):pass
         def visit_table(self, c):pass
         def visit_select(self, select):
@@ -1220,6 +1217,7 @@ class Select(SelectBaseMixin, FromClause):
                 return
             select.is_where = self.is_where
             select.issubquery = True
+            select.useparens = True
             if getattr(select, '_correlated', None) is None:
                 select._correlated = self.select._froms