From: Mike Bayer Date: Fri, 15 Apr 2011 03:44:03 +0000 (-0400) Subject: - fixed bug where "from" clause gathering from an X-Git-Tag: rel_0_7b4~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d34ded2d8a84471be2d1ff03772af9292b36a54;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - fixed bug where "from" clause gathering from an over() clause would be an itertools.chain() and not a list, causing "can only concatenate list" TypeError when combined with other clauses. --- diff --git a/CHANGES b/CHANGES index 5d4d7cd871..16fe6200d5 100644 --- a/CHANGES +++ b/CHANGES @@ -91,6 +91,11 @@ CHANGES will be coerced to integer. [ticket:2116] (also in 0.6.7) + - fixed bug where "from" clause gathering from an + over() clause would be an itertools.chain() and + not a list, causing "can only concatenate list" + TypeError when combined with other clauses. + - engine - The C extension is now enabled by default on CPython 2.x with a fallback to pure python if it fails to diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index f5ec41a60d..c9647e1bd9 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -3704,11 +3704,11 @@ class _Over(ColumnElement): @property def _from_objects(self): - return itertools.chain( + return list(itertools.chain( *[c._from_objects for c in (self.func, self.partition_by, self.order_by) if c is not None] - ) + )) class _Label(ColumnElement): """Represents a column label (AS). diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index ce3e9003bc..abebb7b3ba 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -2146,6 +2146,12 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): "AS anon_1 FROM mytable" ) + # this tests that _from_objects + # concantenates OK + self.assert_compile( + select([column("x") + over(func.foo())]), + "SELECT x + foo() OVER () AS anon_1" + ) def test_date_between(self):