diff options
| -rw-r--r-- | CHANGES | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 2 | ||||
| -rw-r--r-- | test/dialect/oracle.py | 11 |
3 files changed, 9 insertions, 8 deletions
@@ -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(). diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 4def88afa..015701e90 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -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 diff --git a/test/dialect/oracle.py b/test/dialect/oracle.py index 7d544fca5..fa65837f0 100644 --- a/test/dialect/oracle.py +++ b/test/dialect/oracle.py @@ -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', |
