diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-20 15:56:54 -0400 |
---|---|---|
committer | mike bayer <mike_mp@zzzcomputing.com> | 2022-05-22 19:24:18 +0000 |
commit | fbdf8251924571add5478e9ee5a915316a7baa11 (patch) | |
tree | e9cc3e164322bfaf7496425f6c2bc6b2d947015b /lib/sqlalchemy/sql/selectable.py | |
parent | 0620614f95f62f35396e63c636cae98a0759f3ab (diff) | |
download | sqlalchemy-fbdf8251924571add5478e9ee5a915316a7baa11.tar.gz |
render select froms first
The FROM clauses that are established on a :func:`_sql.select` construct
when using the :meth:`_sql.Select.select_from` method will now render first
in the FROM clause of the rendered SELECT, which serves to maintain the
ordering of clauses as was passed to the :meth:`_sql.Select.select_from`
method itself without being affected by the presence of those clauses also
being mentioned in other parts of the query. If other elements of the
:class:`_sql.Select` also generate FROM clauses, such as the columns clause
or WHERE clause, these will render after the clauses delivered by
:meth:`_sql.Select.select_from` assuming they were not explictly passed to
:meth:`_sql.Select.select_from` also. This improvement is useful in those
cases where a particular database generates a desirable query plan based on
a particular ordering of FROM clauses and allows full control over the
ordering of FROM clauses.
Fixes: #7888
Change-Id: I740f262a3841f829239011120a59b5e58452db5b
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 733def377..53dcf51c7 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -4502,6 +4502,7 @@ class SelectState(util.MemoizedSlots, CompileState): return self._normalize_froms( itertools.chain( + self.from_clauses, itertools.chain.from_iterable( [ element._from_objects @@ -4514,7 +4515,6 @@ class SelectState(util.MemoizedSlots, CompileState): for element in statement._where_criteria ] ), - self.from_clauses, ), check_statement=statement, ambiguous_table_name_map=ambiguous_table_name_map, |