summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-11-28 12:37:15 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-11-28 12:37:15 -0500
commitbb60a8ad946dd331f546f06a156b7ebb87d1709d (patch)
treed530604307af524dc87355811fd103718114c258 /lib/sqlalchemy/dialects/postgresql/base.py
parent106e793d0573b5bcd1ddee549bca1a546aa13972 (diff)
downloadsqlalchemy-bb60a8ad946dd331f546f06a156b7ebb87d1709d.tar.gz
- work in progress, will squash
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py44
1 files changed, 16 insertions, 28 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 089769975..091fdeda2 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1015,35 +1015,23 @@ class PGCompiler(compiler.SQLCompiler):
def for_update_clause(self, select):
- tmp = ' FOR UPDATE'
-
- # backwards compatibility
- if isinstance(select.for_update, bool):
- return tmp
- elif isinstance(select.for_update, str):
- if select.for_update == 'nowait':
- return tmp + ' NOWAIT'
- elif select.for_update == 'read':
- return ' FOR SHARE'
- elif select.for_update == 'read_nowait':
- return ' FOR SHARE NOWAIT'
-
- if select.for_update.mode == 'read':
- return ' FOR SHARE'
- elif select.for_update.mode == 'read_nowait':
- return ' FOR SHARE NOWAIT'
-
- if isinstance(select.for_update.of, list):
- tmp += ' OF ' + ', '.join([of[0] for of in select.for_update.of])
- elif isinstance(select.for_update.of, tuple):
- tmp += ' OF ' + select.for_update.of[0]
-
- if select.for_update.mode == 'update_nowait':
- return tmp + ' NOWAIT'
- elif select.for_update.mode == 'update':
- return tmp
+ if select._for_update_arg.read:
+ tmp = " FOR SHARE"
else:
- return super(PGCompiler, self).for_update_clause(select)
+ tmp = " FOR UPDATE"
+
+ if select._for_update_arg.nowait:
+ tmp += " NOWAIT"
+
+ if select._for_update_arg.of:
+ # TODO: assuming simplistic c.table here
+ tables = set(c.table for c in select._for_update_arg.of)
+ tmp += " OF " + ", ".join(
+ self.process(table, asfrom=True)
+ for table in tables
+ )
+
+ return tmp
def returning_clause(self, stmt, returning_cols):