summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-05-03 19:24:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-05-03 19:24:52 -0400
commit9d34c64095b6bed4b36aaea5d0d0e485fcb15d58 (patch)
tree9eb47b5c4ce82ba85a439e9eb1ce1b5b95fee6ba
parent7509fe59ab3d0437b478052cca2329b7c18a8682 (diff)
downloadsqlalchemy-9d34c64095b6bed4b36aaea5d0d0e485fcb15d58.tar.gz
- Fixed use_ansi=False mode, which was producing broken
WHERE clauses in pretty much all cases. [ticket:1790]
-rw-r--r--CHANGES3
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py9
-rw-r--r--test/dialect/test_oracle.py16
3 files changed, 26 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index e110c15e2..5bbc0bb81 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 475730988..6c8055138 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 31e95f57f..b9fb9a133 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',