diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-03-10 23:34:33 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-03-10 23:44:08 -0400 |
| commit | 25fc9562f08fe26e4e2f6d4cf69c34b666f0180a (patch) | |
| tree | aa6647eb6eaa1a16694f0aa1cb3348de61c6594b /lib/sqlalchemy/sql/selectable.py | |
| parent | d514c032cd0349afc93f89d5b99835198ae70112 (diff) | |
| download | sqlalchemy-25fc9562f08fe26e4e2f6d4cf69c34b666f0180a.tar.gz | |
Clone internals for Select._correlate_except collection as well as _correlate
Fixed bug where use of :func:`.with_polymorphic` or other aliased construct
would not properly adapt when the aliased target were used as the
:meth:`.Select.correlate_except` target of a subquery used inside of a
:func:`.column_property`. This required a fix to the clause adaption
mechanics to properly handle a selectable that shows up in the "correlate
except" list, in a similar manner as which occurs for selectables that show
up in the "correlate" list. This is ultimately a fairly fundamental bug
that has lasted for a long time but it is hard to come across it.
Fixes: #4537
Change-Id: Ibb97d4eea18b3c452aad519dd14919bfb84d422f
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
| -rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index cc6d2bcc5..d4528f0c3 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -3227,6 +3227,14 @@ class Select(HasPrefixes, HasSuffixes, GenerativeSelect): self._correlate = set(clone(f) for f in self._correlate).union( self._correlate ) + + # do something similar for _correlate_except - this is a more + # unusual case but same idea applies + if self._correlate_except: + self._correlate_except = set( + clone(f) for f in self._correlate_except + ).union(self._correlate_except) + # 4. clone other things. The difficulty here is that Column # objects are not actually cloned, and refer to their original # .table, resulting in the wrong "from" parent after a clone |
