Commits

Mike Bayer committed 50af5db

- Fixed incorrect usage of "," in over() clause
being placed between the "partition" and "order by"
clauses. [ticket:2134]

  • Participants
  • Parent commits d5be0a2

Comments (0)

Files changed (3)

     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

File lib/sqlalchemy/sql/compiler.py

             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)

File test/sql/test_compiler.py

                 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(
                 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
             ).label('foo')]),