# build up a path indicating the path from the leftmost
# entity to the thing we're subquery loading.
- with_poly_info = path.get(context, "path_with_polymorphic", None)
+ with_poly_info = path.get(context.attributes,
+ "path_with_polymorphic", None)
if with_poly_info is not None:
effective_entity = with_poly_info.entity
else:
# if not via query option, check for
# a cycle
- if not path.contains(context, "loaderstrategy"):
+ if not path.contains(context.attributes, "loaderstrategy"):
if self.join_depth:
if path.length / 2 > self.join_depth:
return
# add new query to attributes to be picked up
# by create_row_processor
- path.set(context, "subquery", q)
+ path.set(context.attributes, "subquery", q)
def _get_leftmost(self, subq_path):
subq_path = subq_path.path
path = path[self.parent_property]
- subq = path.get(context, 'subquery')
+ subq = path.get(context.attributes, 'subquery')
if subq is None:
return None, None, None
# cache the loaded collections in the context
# so that inheriting mappers don't re-load when they
# call upon create_row_processor again
- collections = path.get(context, "collections")
+ collections = path.get(context.attributes, "collections")
if collections is None:
collections = dict(
(k, [v[0] for v in v])
subq,
lambda x: x[1:]
))
- path.set(context, 'collections', collections)
+ path.set(context.attributes, 'collections', collections)
if adapter:
local_cols = [adapter.columns[c] for c in local_cols]
with_polymorphic = None
- user_defined_adapter = path.get(context,
+ user_defined_adapter = path.get(context.attributes,
"user_defined_eager_row_processor",
False)
if user_defined_adapter is not False:
else:
# if not via query option, check for
# a cycle
- if not path.contains(context, "loaderstrategy"):
+ if not path.contains(context.attributes, "loaderstrategy"):
if self.join_depth:
if path.length / 2 > self.join_depth:
return
)
with_poly_info = path.get(
- context,
+ context.attributes,
"path_with_polymorphic",
None
)
adapter = entity._get_entity_clauses(context.query, context)
if adapter and user_defined_adapter:
user_defined_adapter = user_defined_adapter.wrap(adapter)
- path.set(context, "user_defined_eager_row_processor",
+ path.set(context.attributes, "user_defined_eager_row_processor",
user_defined_adapter)
elif adapter:
user_defined_adapter = adapter
- path.set(context, "user_defined_eager_row_processor",
+ path.set(context.attributes, "user_defined_eager_row_processor",
user_defined_adapter)
add_to_collection = context.primary_columns
column_collection, parentmapper, allow_innerjoin
):
with_poly_info = path.get(
- context,
+ context.attributes,
"path_with_polymorphic",
None
)
if self.parent_property.direction != interfaces.MANYTOONE:
context.multi_row_eager_loaders = True
- innerjoin = allow_innerjoin and path.get(context,
+ innerjoin = allow_innerjoin and path.get(context.attributes,
"eager_join_type",
self.parent_property.innerjoin)
if not innerjoin:
)
add_to_collection = context.secondary_columns
- path.set(context, "eager_row_processor", clauses)
+ path.set(context.attributes, "eager_row_processor", clauses)
return clauses, adapter, add_to_collection, allow_innerjoin
)
def _create_eager_adapter(self, context, row, adapter, path):
- user_defined_adapter = path.get(context,
+ user_defined_adapter = path.get(context.attributes,
"user_defined_eager_row_processor",
False)
if user_defined_adapter is not False:
elif context.adapter:
decorator = context.adapter
else:
- decorator = path.get(context, "eager_row_processor")
+ decorator = path.get(context.attributes, "eager_row_processor")
if decorator is None:
return False
def process_query_property(self, query, paths):
if self.chained:
for path in paths:
- path.set(query, "eager_join_type", self.innerjoin)
+ path.set(query._attributes, "eager_join_type", self.innerjoin)
else:
- paths[-1].set(query, "eager_join_type", self.innerjoin)
+ paths[-1].set(query._attributes, "eager_join_type", self.innerjoin)
class LoadEagerFromAliasOption(PropertyOption):
for path in paths[0:-1]:
(root_mapper, prop) = path.path[-2:]
adapter = query._polymorphic_adapters.get(prop.mapper, None)
- path.setdefault(query,
+ path.setdefault(query._attributes,
"user_defined_eager_row_processor",
adapter)
if self.alias is not None:
if isinstance(self.alias, str):
self.alias = prop.target.alias(self.alias)
- paths[-1].set(query, "user_defined_eager_row_processor",
- sql_util.ColumnAdapter(self.alias,
+ paths[-1].set(query._attributes,
+ "user_defined_eager_row_processor",
+ sql_util.ColumnAdapter(self.alias,
equivalents=prop.mapper._equivalent_columns)
)
else:
- if paths[-1].contains(query, "path_with_polymorphic"):
- with_poly_info = paths[-1].get(query, "path_with_polymorphic")
+ if paths[-1].contains(query._attributes, "path_with_polymorphic"):
+ with_poly_info = paths[-1].get(query._attributes,
+ "path_with_polymorphic")
adapter = orm_util.ORMAdapter(
with_poly_info.entity,
equivalents=prop.mapper._equivalent_columns,
adapt_required=True)
else:
adapter = query._polymorphic_adapters.get(prop.mapper, None)
- paths[-1].set(query, "user_defined_eager_row_processor",
- adapter)
+ paths[-1].set(query._attributes,
+ "user_defined_eager_row_processor",
+ adapter)
def single_parent_validator(desc, prop):
return other is not None and \
self.path == other.path
- def set(self, reg, key, value):
- reg._attributes[(key, self.path)] = value
+ def set(self, attributes, key, value):
+ attributes[(key, self.path)] = value
- def setdefault(self, reg, key, value):
- reg._attributes.setdefault((key, self.path), value)
+ def setdefault(self, attributes, key, value):
+ attributes.setdefault((key, self.path), value)
- def get(self, reg, key, value=None):
+ def get(self, attributes, key, value=None):
key = (key, self.path)
- if key in reg._attributes:
- return reg._attributes[key]
+ if key in attributes:
+ return attributes[key]
else:
return value
else:
return False
- def contains(self, reg, key):
- return (key, self.path) in reg._attributes
+ def contains(self, attributes, key):
+ return (key, self.path) in attributes
def __reduce__(self):
return _unreduce_path, (self.serialize(), )
"""
path = dict.__getitem__(self, prop)
path_key = (key, path.path)
- if path_key in context._attributes:
- return context._attributes[path_key]
+ if path_key in context.attributes:
+ return context.attributes[path_key]
else:
return None