]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- figured out a way to get previous oracle behavior back. the ROWID thing
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Nov 2007 19:38:01 +0000 (19:38 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Nov 2007 19:38:01 +0000 (19:38 +0000)
is still a pretty thorny issue.

CHANGES
lib/sqlalchemy/databases/oracle.py
test/dialect/oracle.py

diff --git a/CHANGES b/CHANGES
index c02f0ebb1289b84f0434c4b552f4ea09bf22c90c..7c0c77296e176f3ef6df06ea35be66f8acb362f2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -121,10 +121,6 @@ CHANGES
   - Added test coverage for unknown type reflection. Fixed sqlite/mysql
     handling of type reflection for unknown types.
 
-  - oracle uses plain "rowid" name when limiting against subqueries,
-    since this is the "rowid" of the enclosing query.  if this raises
-    issues in the wild please file tickets !
-
 - misc
 
   - Removed unused util.hash().
index 4def88afa29de96e3860671c154a15f684555845..015701e901c39b6ae7e40a1356d07e874db54e3a 100644 (file)
@@ -646,7 +646,7 @@ class OracleCompiler(compiler.DefaultCompiler):
             # to use ROW_NUMBER(), an ORDER BY is required.
             orderby = self.process(select._order_by_clause)
             if not orderby:
-                orderby = select.oid_column
+                orderby = list(select.oid_column.proxies)[0]
                 orderby = self.process(orderby)
                 
             oldselect = select
index 7d544fca5403abe768c5fbb6efd8373c2529d4d1..fa65837f0efbf58b7f7af574f3cd0439df486d75 100644 (file)
@@ -46,17 +46,22 @@ class CompileTest(SQLCompileTest):
         s = select([t]).limit(10).offset(20)
         
         self.assert_compile(s, "SELECT col1, col2 FROM (SELECT sometable.col1 AS col1, sometable.col2 AS col2, "
-            "ROW_NUMBER() OVER (ORDER BY rowid) AS ora_rn FROM sometable) WHERE ora_rn>20 AND ora_rn<=30"
+            "ROW_NUMBER() OVER (ORDER BY sometable.rowid) AS ora_rn FROM sometable) WHERE ora_rn>20 AND ora_rn<=30"
         )
         
         s = select([s.c.col1, s.c.col2])
         
         self.assert_compile(s, "SELECT col1, col2 FROM (SELECT col1, col2 FROM (SELECT sometable.col1 AS col1, "
-            "sometable.col2 AS col2, ROW_NUMBER() OVER (ORDER BY rowid) AS ora_rn FROM sometable) WHERE ora_rn>20 AND ora_rn<=30)")
+            "sometable.col2 AS col2, ROW_NUMBER() OVER (ORDER BY sometable.rowid) AS ora_rn FROM sometable) WHERE ora_rn>20 AND ora_rn<=30)")
 
         # testing this twice to ensure oracle doesn't modify the original statement 
         self.assert_compile(s, "SELECT col1, col2 FROM (SELECT col1, col2 FROM (SELECT sometable.col1 AS col1, "
-            "sometable.col2 AS col2, ROW_NUMBER() OVER (ORDER BY rowid) AS ora_rn FROM sometable) WHERE ora_rn>20 AND ora_rn<=30)")
+            "sometable.col2 AS col2, ROW_NUMBER() OVER (ORDER BY sometable.rowid) AS ora_rn FROM sometable) WHERE ora_rn>20 AND ora_rn<=30)")
+
+        s = select([t]).limit(10).offset(20).order_by(t.c.col2)
+
+        self.assert_compile(s, "SELECT col1, col2 FROM (SELECT sometable.col1 AS col1, "
+            "sometable.col2 AS col2, ROW_NUMBER() OVER (ORDER BY sometable.col2) AS ora_rn FROM sometable ORDER BY sometable.col2) WHERE ora_rn>20 AND ora_rn<=30")
 
     def test_outer_join(self):
         table1 = table('mytable',