

def _setup_joins(self, pieces, opts, alias):
    '\n        A helper method for get_ordering and get_distinct. This method will\n        call query.setup_joins, handle refcounts and then promote the joins.\n\n        Note that get_ordering and get_distinct must produce same target\n        columns on same input, as the prefixes of get_ordering and get_distinct\n        must match. Executing SQL where this is not true is an error.\n        '
    if (not alias):
        alias = self.query.get_initial_alias()
    (field, targets, opts, joins, _) = self.query.setup_joins(pieces, opts, alias)
    joins_to_promote = [j for j in joins if (self.query.alias_refcount[j] < 2)]
    alias = joins[(- 1)]
    cols = [target.column for target in targets]
    if (not field.rel):
        self.query.ref_alias(alias)
    alias.query.promote_joins(joins_to_promote)
    return (field, cols, alias, joins, opts)

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/models/sql/compiler.py SQLCompiler._setup_joins/VarMisuse@127/291 `self`->`alias`