s.update(c.proxy_set)
return s
+ def _uncached_proxy_set(self):
+ """An 'uncached' version of proxy set.
+
+ This is so that we can read annotations from the list of columns
+ without breaking the caching of the above proxy_set.
+
+ """
+ s = util.column_set([self])
+ for c in self._proxies:
+ s.update(c._uncached_proxy_set())
+ return s
+
def shares_lineage(self, othercolumn):
"""Return True if the given :class:`.ColumnElement`
has a common ancestor to this :class:`.ColumnElement`."""
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)
operator.add,
[
sc._annotations.get("weight", 1)
- for sc in col.proxy_set
+ for sc in col._uncached_proxy_set()
if sc.shares_lineage(column)
],
)
operator.add,
[
sc._annotations.get("weight", 1)
- for sc in c.proxy_set
+ for sc in c._uncached_proxy_set()
if sc.shares_lineage(column)
],
)
# proxy_set, as corresponding_column iterates through proxy_set
# in this way
d = {}
- for col in p2.proxy_set:
+ for col in p2._uncached_proxy_set():
+ d.update(col._annotations)
+ eq_(d, {"weight": 10})
+
+ def test_proxy_set_iteration_includes_annotated_two(self):
+ from sqlalchemy.schema import Column
+
+ c1 = Column("foo", Integer)
+
+ stmt = select([c1]).alias()
+ proxy = stmt.c.foo
+ c1.proxy_set
+
+ proxy._proxies = [c1._annotate({"weight": 10})]
+
+ d = {}
+ for col in proxy._uncached_proxy_set():
d.update(col._annotations)
eq_(d, {"weight": 10})