def _compile_context(self, labels=True):
    context = QueryContext(self)
    if (context.statement is not None):
        return context
    context.labels = labels
    context._for_update_arg = self._for_update_arg
    for entity in self._entities:
        entity.setup_context(self, context)
    for rec in context.create_eager_joins:
        strategy = rec[0]
        strategy(*rec[1:])
    if context.from_clause:
        context.froms = list(context.from_clause)
    else:
        context.froms = context.froms
    if self._enable_single_crit:
        self._adjust_for_single_inheritance(context)
    if (not context.primary_columns):
        if self._only_load_props:
            raise sa_exc.InvalidRequestError('No column-based properties specified for refresh operation. Use session.expire() to reload collections and related items.')
        else:
            raise sa_exc.InvalidRequestError('Query contains no columns with which to SELECT from.')
    if (context.multi_row_eager_loaders and self._should_nest_selectable):
        context.statement = self._compound_eager_statement(context)
    else:
        context.statement = self._simple_statement(context)
    return context
def _compile_context(self, labels=True):
    context = QueryContext(self)
    if (context.statement is not None):
        return context
    context.labels = labels
    context._for_update_arg = self._for_update_arg
    for entity in self._entities:
        entity.setup_context(self, context)
    for rec in context.create_eager_joins:
        strategy = rec[0]
        strategy(*rec[1:])
    if context.from_clause:
        context.froms = list(context.from_clause)
    else:
        context.froms = context.froms
    if self._enable_single_crit:
        self._adjust_for_single_inheritance(context)
    if (not context.primary_columns):
        if self._only_load_props:
            raise sa_exc.InvalidRequestError('No column-based properties specified for refresh operation. Use session.expire() to reload collections and related items.')
        else:
            raise sa_exc.InvalidRequestError('Query contains no columns with which to SELECT from.')
    if (context.multi_row_eager_loaders and self._should_nest_selectable):
        context.statement = self._compound_eager_statement(context)
    else:
        context.statement = self._simple_statement(context)
    return context