

def results_iter(self):
    '\n        Returns an iterator over the results from executing this query.\n        '
    resolve_columns = hasattr(self, 'resolve_columns')
    fields = None
    has_aggregate_select = bool(self.query.aggregate_select)
    for rows in self.execute_sql(MULTI):
        for row in rows:
            if has_aggregate_select:
                loaded_fields = (self.query.get_loaded_field_names().get(self.query.model, set()) or self.query.select)
                aggregate_start = (len(self.query.extra_select) + len(loaded_fields))
                aggregate_end = (aggregate_start + len(self.query.aggregate_select))
            if resolve_columns:
                if (fields is None):
                    if self.query.select:
                        fields = [f.field for f in self.query.select]
                    elif self.query.default_cols:
                        fields = self.query.get_meta().concrete_fields
                    else:
                        fields = []
                    fields = (fields + [f.field for f in self.query.related_select_cols])
                    only_load = self.deferred_to_columns()
                    if only_load:
                        fields = [f for f in fields if ((f.model._meta.db_table not in only_load) or (f.column in only_load[f.model._meta.db_table]))]
                    if has_aggregate_select:
                        fields = ((fields[:aggregate_start] + [None for x in range(0, (aggregate_end - aggregate_start))]) + fields[aggregate_start:])
                row = self.resolve_columns(row, fields)
            if has_aggregate_select:
                row = ((tuple(row[:aggregate_start]) + tuple([self.query.resolve_aggregate(value, aggregate, self.connection) for ((alias, aggregate), value) in zip(self.query.aggregate_select.items(), row[aggregate_start:aggregate_end])])) + tuple(row[aggregate_end:]))
            (yield row)

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/models/sql/compiler.py SQLCompiler.results_iter/original