From 7142a17291deba2eb9d4a2b30e1635129c2284ea Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 21 Mar 2012 22:58:55 -0400 Subject: - [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] --- lib/sqlalchemy/dialects/postgresql/base.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') 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) -- cgit v1.2.1