From: Mike Bayer Date: Mon, 3 May 2010 23:24:52 +0000 (-0400) Subject: - Fixed use_ansi=False mode, which was producing broken X-Git-Tag: rel_0_6_1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d34c64095b6bed4b36aaea5d0d0e485fcb15d58;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed use_ansi=False mode, which was producing broken WHERE clauses in pretty much all cases. [ticket:1790] --- diff --git a/CHANGES b/CHANGES index e110c15e2b..5bbc0bb815 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,9 @@ CHANGES be used. This will impact decimal accuracy and some unicode handling issues. [ticket:1775] + - Fixed use_ansi=False mode, which was producing broken + WHERE clauses in pretty much all cases. [ticket:1790] + - firebird - Added a label to the query used within has_table() and has_sequence() to work with older versions of Firebird diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 475730988f..6c8055138a 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -380,7 +380,8 @@ class OracleCompiler(compiler.SQLCompiler): binary.left = _OuterJoinColumn(binary.left) elif binary.right.table is join.right: binary.right = _OuterJoinColumn(binary.right) - clauses.append(visitors.cloned_traverse(join.onclause, {}, {'binary':visit_binary})) + clauses.append(visitors.cloned_traverse(join.onclause, {}, + {'binary':visit_binary})) else: clauses.append(join.onclause) @@ -391,7 +392,11 @@ class OracleCompiler(compiler.SQLCompiler): for f in froms: if isinstance(f, expression.Join): visit_join(f) - return sql.and_(*clauses) + + if not clauses: + return None + else: + return sql.and_(*clauses) def visit_outer_join_column(self, vc): return self.process(vc.column) + "(+)" diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index 31e95f57f7..b9fb9a1337 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -280,6 +280,22 @@ class CompileTest(TestBase, AssertsCompiledSQL): "WHERE mytable.myid = myothertable.otherid(+)) anon_1 " "WHERE thirdtable.userid = anon_1.myid(+)", dialect=oracle.dialect(use_ansi=False)) + + q = select([table1.c.name]).where(table1.c.name=='foo') + self.assert_compile(q, + "SELECT mytable.name FROM mytable WHERE mytable.name = :name_1", + dialect=oracle.dialect(use_ansi=False)) + + subq = select([table3.c.otherstuff]).\ + where(table3.c.otherstuff==table1.c.name).\ + label('bar') + q = select([table1.c.name, subq]) + self.assert_compile(q, + "SELECT mytable.name, " + "(SELECT thirdtable.otherstuff FROM thirdtable " + "WHERE thirdtable.otherstuff = mytable.name) AS bar FROM mytable", + dialect=oracle.dialect(use_ansi=False)) + def test_alias_outer_join(self): address_types = table('address_types',