diff options
author | Mario Lassnig <mario@lassnig.net> | 2013-11-28 14:50:41 +0100 |
---|---|---|
committer | Mario Lassnig <mario@lassnig.net> | 2013-11-28 14:50:41 +0100 |
commit | e9aaf8eb66343f247b1ec2189707f820e20a0629 (patch) | |
tree | fe5af6902c88668146b278b5494941d545d9233a /lib/sqlalchemy/dialects | |
parent | 741da873841012d893ec08bd77a5ecc9237eaab8 (diff) | |
download | sqlalchemy-e9aaf8eb66343f247b1ec2189707f820e20a0629.tar.gz |
added LockmodeArgspr/42
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 22 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 30 |
3 files changed, 45 insertions, 16 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 6883be5af..d70e9b606 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1422,7 +1422,14 @@ class MySQLCompiler(compiler.SQLCompiler): self.process(join.onclause, **kwargs))) def for_update_clause(self, select): - if select.for_update == 'read': + # backwards compatibility + if isinstance(select.for_update, bool): + return ' FOR UPDATE' + elif isinstance(select.for_update, str): + if select.for_update == 'read': + return ' LOCK IN SHARE MODE' + + if select.for_update.mode == 'read': return ' LOCK IN SHARE MODE' else: return super(MySQLCompiler, self).for_update_clause(select) diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 74441e9a8..c0d9732b4 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -664,14 +664,24 @@ class OracleCompiler(compiler.SQLCompiler): tmp = ' FOR UPDATE' - if isinstance(select.for_update_of, list): - tmp += ' OF ' + ', '.join(['.'.join(of) for of in select.for_update_of]) - elif isinstance(select.for_update_of, tuple): - tmp += ' OF ' + '.'.join(select.for_update_of) + # backwards compatibility + if isinstance(select.for_update, bool): + if select.for_update: + return tmp + elif isinstance(select.for_update, str): + if select.for_update == 'nowait': + return tmp + ' NOWAIT' + else: + return tmp + + if isinstance(select.for_update.of, list): + tmp += ' OF ' + ', '.join(['.'.join(of) for of in select.for_update.of]) + elif isinstance(select.for_update.of, tuple): + tmp += ' OF ' + '.'.join(select.for_update.of) - if select.for_update == 'nowait': + if select.for_update.mode == 'update_nowait': return tmp + ' NOWAIT' - elif select.for_update: + elif select.for_update.mode == 'update': return tmp else: return super(OracleCompiler, self).for_update_clause(select) diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index ec22e8633..089769975 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1015,20 +1015,32 @@ class PGCompiler(compiler.SQLCompiler): def for_update_clause(self, select): - if select.for_update == 'read': + 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 == 'read_nowait': + elif select.for_update.mode == 'read_nowait': return ' FOR SHARE NOWAIT' - tmp = ' FOR UPDATE' - 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 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 == 'nowait': + if select.for_update.mode == 'update_nowait': return tmp + ' NOWAIT' - elif select.for_update: + elif select.for_update.mode == 'update': return tmp else: return super(PGCompiler, self).for_update_clause(select) |