

def pre_sql_setup(self):
    '\n        If the update depends on results from other tables, we need to do some\n        munging of the "where" conditions to match the format required for\n        (portable) SQL updates. That is done here.\n\n        Further, if we are going to be running multiple updates, we pull out\n        the id values to update at this point so that they don\'t change as a\n        result of the progressive updates.\n        '
    self.query.select_related = False
    self.query.clear_ordering(True)
    super(SQLUpdateCompiler, self).pre_sql_setup()
    count = self.query.count_active_tables()
    if ((not self.query.related_updates) and (count == 1)):
        return
    query = self.query.clone(klass=Query)
    query.bump_prefix()
    query.extra = {
        
    }
    query.select = []
    query.add_fields([query.get_meta().pk.name])
    count = query.count_active_tables()
    if ((not self.query.related_updates) and (count == 1)):
        return
    must_pre_select = ((count > 1) and (not self.connection.features.update_can_self_select))
    self.query.where = self.query.where_class()
    if (self.query.related_updates or must_pre_select):
        idents = []
        for rows in query.get_compiler(self.using).execute_sql(MULTI):
            idents.extend([r[0] for r in rows])
        self.query.add_filter(('pk__in', idents))
        self.query.related_ids = idents
    else:
        self.query.add_filter(('pk__in', query))
    for alias in self.query.tables[1:]:
        self.query.alias_refcount[alias] = 0

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