summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-05-27 11:50:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-05-27 11:50:16 -0400
commit40c7db67b46fac0029f8caf7a53cbceb05a2324d (patch)
treee695096e217a76a7d5c889f7f0de25613f8d5ac0 /lib/sqlalchemy
parent6033b074094d96f17640cc9ab8ea86e6de94927a (diff)
downloadsqlalchemy-40c7db67b46fac0029f8caf7a53cbceb05a2324d.tar.gz
- FOR UPDATE is emitted in the syntactically correct position
when limit/offset is used, i.e. the ROWNUM subquery. However, Oracle can't really handle FOR UPDATE with ORDER BY or with subqueries, so its still not very usable, but at least SQLA gets the SQL past the Oracle parser. [ticket:1815]
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index 6c8055138..cd232fa00 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -479,7 +479,7 @@ class OracleCompiler(compiler.SQLCompiler):
limitselect._oracle_visit = True
limitselect._is_wrapper = True
-
+
# If needed, add the limiting clause
if select._limit is not None:
max_row = select._limit
@@ -490,22 +490,24 @@ class OracleCompiler(compiler.SQLCompiler):
# If needed, add the ora_rn, and wrap again with offset.
if select._offset is None:
+ limitselect.for_update = select.for_update
select = limitselect
else:
- limitselect = limitselect.column(
+ limitselect = limitselect.column(
sql.literal_column("ROWNUM").label("ora_rn"))
- limitselect._oracle_visit = True
- limitselect._is_wrapper = True
+ limitselect._oracle_visit = True
+ limitselect._is_wrapper = True
- offsetselect = sql.select(
+ offsetselect = sql.select(
[c for c in limitselect.c if c.key!='ora_rn'])
- offsetselect._oracle_visit = True
- offsetselect._is_wrapper = True
+ offsetselect._oracle_visit = True
+ offsetselect._is_wrapper = True
- offsetselect.append_whereclause(
+ offsetselect.append_whereclause(
sql.literal_column("ora_rn")>select._offset)
- select = offsetselect
+ offsetselect.for_update = select.for_update
+ select = offsetselect
kwargs['iswrapper'] = getattr(select, '_is_wrapper', False)
return compiler.SQLCompiler.visit_select(self, select, **kwargs)
@@ -514,7 +516,9 @@ class OracleCompiler(compiler.SQLCompiler):
return ""
def for_update_clause(self, select):
- if select.for_update == "nowait":
+ if self.is_subquery():
+ return ""
+ elif select.for_update == "nowait":
return " FOR UPDATE NOWAIT"
else:
return super(OracleCompiler, self).for_update_clause(select)