]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed Oracle non-ansi join syntax
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 10 Oct 2007 02:30:00 +0000 (02:30 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 10 Oct 2007 02:30:00 +0000 (02:30 +0000)
CHANGES
lib/sqlalchemy/databases/oracle.py
test/dialect/oracle.py

diff --git a/CHANGES b/CHANGES
index 2723504ef9b188f1e3deca0661255289fb9780d9..30ae3cc5c050ca9d1c52a6c26137f65ca12ec33a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -55,6 +55,8 @@ CHANGES
 - Added an option to the _ScopedExt mapper extension to not automatically
   save new objects to session on object initialization.
 
+- fixed Oracle non-ansi join syntax
+
 0.4.0beta6
 ----------
 
index 951f97e38dadb0e4218c82cd57f16f7331c3e5de..848a68ff3527af9da94bfff6ee05bbb3efcdc5cc 100644 (file)
@@ -577,12 +577,18 @@ class OracleCompiler(compiler.DefaultCompiler):
                         binary.left = _OuterJoinColumn(binary.left)
                     elif binary.right.table is join.right:
                         binary.right = _OuterJoinColumn(binary.right)
-                        
-        if where is not None:
-            self.__wheres[join.left] = self.__wheres[parentjoin] = (sql.and_(VisitOn().traverse(join.onclause, clone=True), where), parentjoin)
+        
+        if join.isouter:
+            if where is not None:
+                self.__wheres[join.left] = self.__wheres[parentjoin] = (sql.and_(VisitOn().traverse(join.onclause, clone=True), where), parentjoin)
+            else:
+                self.__wheres[join.left] = self.__wheres[join] = (VisitOn().traverse(join.onclause, clone=True), join)
         else:
-            self.__wheres[join.left] = self.__wheres[join] = (VisitOn().traverse(join.onclause, clone=True), join)
-
+            if where is not None:
+                self.__wheres[join.left] = self.__wheres[parentjoin] = (sql.and_(join.onclause, where), parentjoin)
+            else:
+                self.__wheres[join.left] = self.__wheres[join] = (join.onclause, join)
+            
         return self.process(join.left, asfrom=True) + ", " + self.process(join.right, asfrom=True)
     
     def get_whereclause(self, f):
index f993536167f0538429304bfbb78ab1e6a1b05c88..2ad0c4bebbe87476422245d0cd96ef3e039f7473 100644 (file)
@@ -97,6 +97,9 @@ myothertable.othername != :myothertable_othername OR EXISTS (select yay from foo
         query = table1.outerjoin(table2, table1.c.myid==table2.c.otherid).outerjoin(table3, table3.c.userid==table2.c.otherid)
         self.assert_compile(query.select(), "SELECT mytable.myid, mytable.name, mytable.description, myothertable.otherid, myothertable.othername, thirdtable.userid, thirdtable.otherstuff FROM mytable LEFT OUTER JOIN myothertable ON mytable.myid = myothertable.otherid LEFT OUTER JOIN thirdtable ON thirdtable.userid = myothertable.otherid")
         self.assert_compile(query.select(), "SELECT mytable.myid, mytable.name, mytable.description, myothertable.otherid, myothertable.othername, thirdtable.userid, thirdtable.otherstuff FROM mytable, myothertable, thirdtable WHERE mytable.myid = myothertable.otherid(+) AND thirdtable.userid(+) = myothertable.otherid", dialect=oracle.dialect(use_ansi=False))    
+
+        query = table1.join(table2, table1.c.myid==table2.c.otherid).join(table3, table3.c.userid==table2.c.otherid)
+        self.assert_compile(query.select(), "SELECT mytable.myid, mytable.name, mytable.description, myothertable.otherid, myothertable.othername, thirdtable.userid, thirdtable.otherstuff FROM mytable, myothertable, thirdtable WHERE mytable.myid = myothertable.otherid AND thirdtable.userid = myothertable.otherid", dialect=oracle.dialect(use_ansi=False))    
     
     def test_alias_outer_join(self):
         address_types = table('address_types',