summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-03-21 22:58:55 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-03-21 22:58:55 -0400
commit7142a17291deba2eb9d4a2b30e1635129c2284ea (patch)
treeaa0364a5a29d315c8ec7ea6f3ac402a6425ffa6b /lib/sqlalchemy/dialects
parent565b5dc537e8c155fb85878d477180a4c954b81f (diff)
downloadsqlalchemy-7142a17291deba2eb9d4a2b30e1635129c2284ea.tar.gz
- [feature] Added new for_update/with_lockmode()
options for Postgresql: for_update="read"/ with_lockmode("read"), for_update="read_nowait"/ with_lockmode("read_nowait"). These emit "FOR SHARE" and "FOR SHARE NOWAIT", respectively. Courtesy Diana Clarke [ticket:2445]
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index e87c0426e..c31c23885 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -675,6 +675,10 @@ class PGCompiler(compiler.SQLCompiler):
def for_update_clause(self, select):
if select.for_update == 'nowait':
return " FOR UPDATE NOWAIT"
+ elif select.for_update == 'read':
+ return " FOR SHARE"
+ elif select.for_update == 'read_nowait':
+ return " FOR SHARE NOWAIT"
else:
return super(PGCompiler, self).for_update_clause(select)