diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-11-28 12:37:15 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-11-28 12:37:15 -0500 |
| commit | bb60a8ad946dd331f546f06a156b7ebb87d1709d (patch) | |
| tree | d530604307af524dc87355811fd103718114c258 /lib/sqlalchemy/dialects | |
| parent | 106e793d0573b5bcd1ddee549bca1a546aa13972 (diff) | |
| download | sqlalchemy-bb60a8ad946dd331f546f06a156b7ebb87d1709d.tar.gz | |
- work in progress, will squash
Diffstat (limited to 'lib/sqlalchemy/dialects')
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 13 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 31 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 44 |
3 files changed, 29 insertions, 59 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 324ff2d36..971005a84 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1437,17 +1437,10 @@ class MySQLCompiler(compiler.SQLCompiler): self.process(join.onclause, **kwargs))) def for_update_clause(self, select): - # 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' + if select._for_update_arg.read: + return " LOCK IN SHARE MODE" else: - return super(MySQLCompiler, self).for_update_clause(select) + return " FOR UPDATE" def limit_clause(self, select): # MySQL supports: diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 0bd009807..a3c31b7cc 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -632,7 +632,7 @@ 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 + limitselect._for_update_arg = select._for_update_arg select = limitselect else: limitselect = limitselect.column( @@ -651,7 +651,7 @@ class OracleCompiler(compiler.SQLCompiler): offsetselect.append_whereclause( sql.literal_column("ora_rn") > offset_value) - offsetselect.for_update = select.for_update + offsetselect._for_update_arg = select._for_update_arg select = offsetselect kwargs['iswrapper'] = getattr(select, '_is_wrapper', False) @@ -666,27 +666,16 @@ class OracleCompiler(compiler.SQLCompiler): tmp = ' FOR UPDATE' - # 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 select._for_update_arg.nowait: + tmp += " NOWAIT" - 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_arg.of: + tmp += ' OF ' + ', '.join( + self._process(elem) for elem in + select._for_update_arg.of + ) - if select.for_update.mode == 'update_nowait': - return tmp + ' NOWAIT' - elif select.for_update.mode == 'update': - return tmp - else: - return super(OracleCompiler, self).for_update_clause(select) + return tmp class OracleDDLCompiler(compiler.DDLCompiler): 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): |
