From: Mike Bayer Date: Fri, 4 Apr 2008 16:06:58 +0000 (+0000) Subject: fixed union() bug whereby oid_column would not be available if no oid_column in embed... X-Git-Tag: rel_0_5beta1~201 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a684567958d548f7ed68ba34bc17bffbadfb8ee;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fixed union() bug whereby oid_column would not be available if no oid_column in embedded selects --- diff --git a/CHANGES b/CHANGES index f66bc798cf..b0fbbc8012 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,12 @@ ======= CHANGES ======= - +0.4.6 +===== +- sql + - Fixed bug with union() when applied to non-Table connected + select statements + 0.4.5 ===== - orm diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9272e6d82c..2ed3b372f2 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2993,11 +2993,14 @@ class CompoundSelect(_SelectBaseMixin, FromClause): self.selects.append(s) _SelectBaseMixin.__init__(self, **kwargs) - + + self.oid_column = None for s in self.selects: + # TODO: need to repair proxy_column here to + # not require full traversal if s.oid_column: self.oid_column = self._proxy_column(s.oid_column) - + def self_group(self, against=None): return _FromGrouping(self) diff --git a/test/sql/select.py b/test/sql/select.py index 06679e9564..77926b421b 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -888,6 +888,13 @@ SELECT thirdtable.userid FROM thirdtable)" "SELECT myothertable.otherid FROM myothertable EXCEPT SELECT thirdtable.userid FROM thirdtable \ UNION SELECT mytable.myid FROM mytable" ) + + # test unions working with non-oid selectables + s = select([column('foo'), column('bar')]) + s = union(s, s) + s = union(s, s) + self.assert_compile(s, "SELECT foo, bar UNION SELECT foo, bar UNION (SELECT foo, bar UNION SELECT foo, bar)") + @testing.uses_deprecated('//get_params') def test_binds(self):