From: Mike Bayer Date: Sun, 17 Apr 2011 17:40:37 +0000 (-0400) Subject: - Fixed incorrect usage of "," in over() clause X-Git-Tag: rel_0_7b4~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=509f3fb492a4be70842dde65f9b84a86671e857f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed incorrect usage of "," in over() clause being placed between the "partition" and "order by" clauses. [ticket:2134] --- diff --git a/CHANGES b/CHANGES index 16fe6200d5..3aaf6f85f2 100644 --- a/CHANGES +++ b/CHANGES @@ -96,6 +96,10 @@ CHANGES not a list, causing "can only concatenate list" TypeError when combined with other clauses. + - Fixed incorrect usage of "," in over() clause + being placed between the "partition" and "order by" + clauses. [ticket:2134] + - 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/compiler.py b/lib/sqlalchemy/sql/compiler.py index 7c409e0e63..fe04da1a1b 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -468,7 +468,7 @@ class SQLCompiler(engine.Compiled): x += "PARTITION BY %s" % \ over.partition_by._compiler_dispatch(self, **kwargs) if over.order_by is not None: - x += ", " + x += " " if over.order_by is not None: x += "ORDER BY %s" % \ over.order_by._compiler_dispatch(self, **kwargs) diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index abebb7b3ba..678411fe2c 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -2094,7 +2094,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): partition_by=[table1.c.name], order_by=[table1.c.description] ), - "row_number() OVER (PARTITION BY mytable.name, " + "row_number() OVER (PARTITION BY mytable.name " "ORDER BY mytable.description)" ) self.assert_compile( @@ -2102,10 +2102,19 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): partition_by=table1.c.name, order_by=table1.c.description ), - "row_number() OVER (PARTITION BY mytable.name, " + "row_number() OVER (PARTITION BY mytable.name " "ORDER BY mytable.description)" ) + self.assert_compile( + func.row_number().over( + partition_by=table1.c.name, + order_by=[table1.c.name, table1.c.description] + ), + "row_number() OVER (PARTITION BY mytable.name " + "ORDER BY mytable.name, mytable.description)" + ) + self.assert_compile( select([func.row_number().over( order_by=table1.c.description