]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed incorrect usage of "," in over() clause
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Apr 2011 17:40:37 +0000 (13:40 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Apr 2011 17:40:37 +0000 (13:40 -0400)
being placed between the "partition" and "order by"
clauses.  [ticket:2134]

CHANGES
lib/sqlalchemy/sql/compiler.py
test/sql/test_compiler.py

diff --git a/CHANGES b/CHANGES
index 16fe6200d5780716aec66796b3b67073e7421728..3aaf6f85f2f68ce2e4241fff7135ec33c49c59d7 100644 (file)
--- 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
index 7c409e0e637ba2db8fe7e2ffe2e9b6bd683d6f62..fe04da1a1b5a6b43cee669ca01daa5a9131f8ef7 100644 (file)
@@ -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)
index abebb7b3ba803f5641a99a618ea7c272aaae458f..678411fe2c89ed02602e9d15cdcca7ea5d2fa245 100644 (file)
@@ -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