diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-01 22:33:26 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-02 09:57:20 -0400 |
commit | 6636cd9d256ccbad651eba6553ec46391380cc93 (patch) | |
tree | 156326031c15adc3f09f885194d230a2039a74a4 /lib/sqlalchemy/sql/elements.py | |
parent | 3b60ccaed4844d25617221c853b3e46a78fd7974 (diff) | |
download | sqlalchemy-6636cd9d256ccbad651eba6553ec46391380cc93.tar.gz |
Clear proxy_set cache when creating an annotated column
Fixed an unlikely issue where the "corresponding column" routine for unions
and other :class:`.CompoundSelect` objects could return the wrong column in
some overlapping column situtations, thus potentially impacting some ORM
operations when set operations are in use, if the underlying
:func:`.select` constructs were used previously in other similar kinds of
routines, due to a cached value not being cleared.
Fixes: #4747
Change-Id: I7fb134cac3604f8fe62e220fb24a0945d0a1c56f
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index cc57e58e5..aa7b7f688 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -635,6 +635,7 @@ class ColumnElement( __visit_name__ = "column_element" primary_key = False foreign_keys = [] + _proxies = () _label = None """The named label that can be used to target @@ -783,16 +784,13 @@ class ColumnElement( @util.memoized_property def base_columns(self): - return util.column_set( - c for c in self.proxy_set if not hasattr(c, "_proxies") - ) + return util.column_set(c for c in self.proxy_set if not c._proxies) @util.memoized_property def proxy_set(self): s = util.column_set([self]) - if hasattr(self, "_proxies"): - for c in self._proxies: - s.update(c.proxy_set) + for c in self._proxies: + s.update(c.proxy_set) return s def shares_lineage(self, othercolumn): @@ -4388,6 +4386,8 @@ class AnnotatedColumnElement(Annotated): def __init__(self, element, values): Annotated.__init__(self, element, values) ColumnElement.comparator._reset(self) + if self._proxies: + ColumnElement.proxy_set._reset(self) for attr in ("name", "key", "table"): if self.__dict__.get(attr, False) is None: self.__dict__.pop(attr) |