]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed bug introduced in r4070 where union() and other compound selects would not get
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Feb 2008 21:16:31 +0000 (21:16 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Feb 2008 21:16:31 +0000 (21:16 +0000)
an OID column if it only contained one selectable element, due to missing return in _proxy_column()
- visit_column() calls itself to render a primary key col being used as the interpretation of the oid col instead of relying upon broken partial logic

lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/expression.py
test/sql/selectable.py

index 02f6efce184cec2b6e0eebd64dabcaa1e824c173..e87d3d2fb4a3f90283395267240e73c2bf4b1337 100644 (file)
@@ -269,8 +269,7 @@ class DefaultCompiler(engine.Compiled):
                     return schema_prefix + self.preparer.quote(column.table, ANONYMOUS_LABEL.sub(self._process_anon, column.table.name)) + "." + n
             elif len(column.table.primary_key) != 0:
                 pk = list(column.table.primary_key)[0]
-                pkname = (pk.is_literal and name or self._truncated_identifier("colident", pk.name))
-                return schema_prefix + self.preparer.quote(column.table, ANONYMOUS_LABEL.sub(self._process_anon, column.table.name)) + "." + self.preparer.quote(pk, pkname)
+                return self.visit_column(pk, result_map=result_map, use_schema=use_schema, **kwargs)
             else:
                 return None
         elif column.table is None or not column.table.named_with_column:
index 79eb1759d3d01baa4f7daf31eefa71aa56ae5ff0..0b76848039ae5427513c44ef711d45bb71e6b1e7 100644 (file)
@@ -2935,7 +2935,6 @@ class CompoundSelect(_SelectBaseMixin, FromClause):
             if s.oid_column:
                 self.oid_column = self._proxy_column(s.oid_column)
 
-
     def self_group(self, against=None):
         return _FromGrouping(self)
 
@@ -2956,6 +2955,7 @@ class CompoundSelect(_SelectBaseMixin, FromClause):
             else:
                 col = column._make_proxy(self)
             col_ordering.append(col)
+            return col
         else:
             col_ordering.append(column)
             existing = self._col_map[self.selects[0]][len(col_ordering) - 1]
index c93c6282591afafb026761053ee14bb0f33a0c06..3ad296aaa17ab9caf46d394f58441f4b2787b535 100755 (executable)
@@ -92,6 +92,16 @@ class SelectableTest(TestBase, AssertsExecutionResults):
         assert u.corresponding_column(s1.c.table1_col2) is u.c.col2
         assert u.corresponding_column(s2.c.table2_col2) is u.c.col2
 
+    def test_singular_union(self):
+        u = union(select([table.c.col1, table.c.col2, table.c.col3]), select([table.c.col1, table.c.col2, table.c.col3]))
+        assert u.oid_column is not None
+
+        u = union(select([table.c.col1, table.c.col2, table.c.col3]))
+        assert u.oid_column
+        assert u.c.col1
+        assert u.c.col2
+        assert u.c.col3
+        
     def testaliasunion(self):
         # same as testunion, except its an alias of the union
         u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(