From 2d34ded2d8a84471be2d1ff03772af9292b36a54 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 14 Apr 2011 23:44:03 -0400 Subject: [PATCH] - 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. --- CHANGES | 5 +++++ lib/sqlalchemy/sql/expression.py | 4 ++-- test/sql/test_compiler.py | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) 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): -- 2.39.5