def setup_context(self, query, context):
    adapter = self._get_entity_clauses(query, context)
    context.froms += (self.selectable,)
    if ((context.order_by is False) and self.mapper.order_by):
        context.order_by = self.mapper.order_by
        if adapter:
            context.order_by = adapter.adapt_list(util.to_list(context.order_by))
    if self._with_polymorphic:
        poly_properties = self.mapper._iterate_polymorphic_properties(self._with_polymorphic)
    else:
        poly_properties = self.mapper._polymorphic_properties
    for value in poly_properties:
        if (query._only_load_props and (value.key not in query._only_load_props)):
            continue
        value.setup(context, self, self.path, adapter, only_load_props=query._only_load_props, column_collection=context.primary_columns)
    if ((self._polymorphic_discriminator is not None) and (self._polymorphic_discriminator is not self.mapper.polymorphic_on)):
        if adapter:
            pd = adapter.columns[self._polymorphic_discriminator]
        else:
            pd = self._polymorphic_discriminator
        context.primary_columns.append(pd)
def setup_context(self, query, context):
    adapter = self._get_entity_clauses(query, context)
    context.froms += (self.selectable,)
    if ((context.order_by is False) and self.mapper.order_by):
        context.order_by = self.mapper.order_by
        if adapter:
            context.order_by = adapter.adapt_list(util.to_list(context.order_by))
    if self._with_polymorphic:
        poly_properties = self.mapper._iterate_polymorphic_properties(self._with_polymorphic)
    else:
        poly_properties = self.mapper._polymorphic_properties
    for value in poly_properties:
        if (query._only_load_props and (value.key not in query._only_load_props)):
            continue
        value.setup(context, self, self.path, adapter, only_load_props=query._only_load_props, column_collection=context.primary_columns)
    if ((self._polymorphic_discriminator is not None) and (self._polymorphic_discriminator is not self.mapper.polymorphic_on)):
        if adapter:
            pd = adapter.columns[self._polymorphic_discriminator]
        else:
            pd = self._polymorphic_discriminator
        context.primary_columns.append(pd)