diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-29 14:17:42 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-29 16:46:56 -0400 |
commit | f483573aa640efb79e8b1ec6c1faac6f79d9d8fe (patch) | |
tree | d53426d5ca4424647c0bd711c8ce0c5e548e4fe0 /lib/sqlalchemy/sql/dml.py | |
parent | 147f0969301184b952366f39195caaabe6d63dbf (diff) | |
download | sqlalchemy-f483573aa640efb79e8b1ec6c1faac6f79d9d8fe.tar.gz |
Scan for tables without relying upon whereclause
Fixed bug where an UPDATE statement against a JOIN using MySQL multi-table
format would fail to include the table prefix for the target table if the
statement had no WHERE clause, as only the WHERE clause were scanned to
detect a "multi table update" at that particular point. The target
is now also scanned if it's a JOIN to get the leftmost table as the
primary table and the additional entries as additional FROM entries.
Fixes: #5617
Change-Id: I26d74afebe06e28af28acf960258f170a1627823
Diffstat (limited to 'lib/sqlalchemy/sql/dml.py')
-rw-r--r-- | lib/sqlalchemy/sql/dml.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/dml.py b/lib/sqlalchemy/sql/dml.py index 5ddc9ef82..c923bf651 100644 --- a/lib/sqlalchemy/sql/dml.py +++ b/lib/sqlalchemy/sql/dml.py @@ -12,6 +12,7 @@ Provide :class:`_expression.Insert`, :class:`_expression.Update` and from sqlalchemy.types import NullType from . import coercions from . import roles +from . import util as sql_util from .base import _entity_namespace_key from .base import _from_objects from .base import _generative @@ -47,7 +48,9 @@ class DMLState(CompileState): def _make_extra_froms(self, statement): froms = [] - seen = {statement.table} + + all_tables = list(sql_util.tables_from_leftmost(statement.table)) + seen = {all_tables[0]} for crit in statement._where_criteria: for item in _from_objects(crit): @@ -55,6 +58,7 @@ class DMLState(CompileState): froms.append(item) seen.update(item._cloned_set) + froms.extend(all_tables[1:]) return froms def _process_multi_values(self, statement): |