From: Mike Bayer Date: Mon, 5 Nov 2007 19:38:01 +0000 (+0000) Subject: - figured out a way to get previous oracle behavior back. the ROWID thing X-Git-Tag: rel_0_4_1~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=724eb54efd498a772dc3d4db209c50592f2a158c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - figured out a way to get previous oracle behavior back. the ROWID thing is still a pretty thorny issue. --- diff --git a/CHANGES b/CHANGES index c02f0ebb12..7c0c77296e 100644 --- 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(). diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 4def88afa2..015701e901 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 7d544fca54..fa65837f0e 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',