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/util.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/util.py')
-rw-r--r-- | lib/sqlalchemy/sql/util.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 96fa209fd..e4f7532be 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -366,6 +366,19 @@ def clause_is_present(clause, search): return False +def tables_from_leftmost(clause): + if isinstance(clause, Join): + for t in tables_from_leftmost(clause.left): + yield t + for t in tables_from_leftmost(clause.right): + yield t + elif isinstance(clause, FromGrouping): + for t in tables_from_leftmost(clause.element): + yield t + else: + yield clause + + def surface_selectables(clause): stack = [clause] while stack: |