

def calculate_alias_map(self, query, alias_map=None):
    new_map = self.alias_map_class()
    if (alias_map is not None):
        new_map._counter = alias_map._counter
    new_map.add(query.model_class, query.model_class._meta.table_alias)
    for (src_model, joined_models) in query._joins.items():
        new_map.add(src_model, src_model._meta.table_alias)
        for join_obj in joined_models:
            if isinstance(join_obj.dest, Node):
                new_map.add(join_obj.dest, join_obj.dest.alias)
            else:
                new_map.add(join_obj.dest, join_obj.dest._meta.table_alias)
    return new_map.update(alias_map)

dataset/ETHPy150Open coleifer/peewee/peewee.py QueryCompiler.calculate_alias_map/original