def __init__(self, query, column, namespace=None):
    self.expr = column
    self.namespace = namespace
    if isinstance(column, util.string_types):
        column = sql.literal_column(column)
        self._label_name = column.name
    elif isinstance(column, (attributes.QueryableAttribute, interfaces.PropComparator)):
        self._label_name = column.key
        column = column._query_clause_element()
    else:
        self._label_name = getattr(column, 'key', None)
    if ((not isinstance(column, expression.ColumnElement)) and hasattr(column, '_select_iterable')):
        for c in column._select_iterable:
            if (c is column):
                break
            _ColumnEntity(query, c, namespace=column)
        else:
            return
    elif isinstance(column, Bundle):
        _BundleEntity(query, column)
        return
    if (not isinstance(column, sql.ColumnElement)):
        raise sa_exc.InvalidRequestError(("SQL expression, column, or mapped entity expected - got '%r'" % (column,)))
    self.type = type_ = column.type
    if type_.hashable:
        self.filter_fn = (lambda item: item)
    else:
        counter = util.counter()
        self.filter_fn = (lambda item: counter())
    if ((not column._label) and (not getattr(column, 'is_literal', False))):
        column = column.label(self._label_name)
    query._entities.append(self)
    self.column = column
    self.froms = set()
    self.actual_froms = actual_froms = set(column._from_objects)
    self.entities = util.OrderedSet((elem._annotations['parententity'] for elem in visitors.iterate(column, {}) if (('parententity' in elem._annotations) and actual_froms.intersection(elem._from_objects))))
    if self.entities:
        self.entity_zero = list(self.entities)[0]
    elif (self.namespace is not None):
        self.entity_zero = self.namespace
    else:
        self.entity_zero = None
def __init__(self, query, column, namespace=None):
    self.expr = column
    self.namespace = namespace
    if isinstance(column, util.string_types):
        column = sql.literal_column(column)
        self._label_name = column.name
    elif isinstance(column, (attributes.QueryableAttribute, interfaces.PropComparator)):
        self._label_name = column.key
        column = column._query_clause_element()
    else:
        self._label_name = getattr(column, 'key', None)
    if ((not isinstance(column, expression.ColumnElement)) and hasattr(column, '_select_iterable')):
        for c in column._select_iterable:
            if (c is column):
                break
            _ColumnEntity(query, c, namespace=column)
        else:
            return
    elif isinstance(column, Bundle):
        _BundleEntity(query, column)
        return
    if (not isinstance(column, sql.ColumnElement)):
        raise sa_exc.InvalidRequestError(("SQL expression, column, or mapped entity expected - got '%r'" % (column,)))
    self.type = type_ = column.type
    if type_.hashable:
        self.filter_fn = (lambda item: item)
    else:
        counter = util.counter()
        self.filter_fn = (lambda item: counter())
    if ((not column._label) and (not getattr(column, 'is_literal', False))):
        column = column.label(self._label_name)
    query._entities.append(self)
    self.column = column
    self.froms = set()
    self.actual_froms = actual_froms = set(column._from_objects)
    self.entities = util.OrderedSet((elem._annotations['parententity'] for elem in visitors.iterate(column, {}) if (('parententity' in elem._annotations) and actual_froms.intersection(elem._from_objects))))
    if self.entities:
        self.entity_zero = list(self.entities)[0]
    elif (self.namespace is not None):
        self.entity_zero = self.namespace
    else:
        self.entity_zero = None