def as_sql(self):
    '\n        Creates the SQL for this query. Returns the SQL string and list of\n        parameters.\n        '
    self.pre_sql_setup()
    if (not self.query.values):
        return ('', ())
    table = self.query.tables[0]
    qn = self.quote_name_unless_alias
    result = [('UPDATE %s' % qn(table))]
    result.append('SET')
    (values, update_params) = ([], [])
    for (field, model, val) in self.query.values:
        if hasattr(val, 'resolve_expression'):
            val = val.resolve_expression(self.query, allow_joins=False, for_save=True)
            if val.contains_aggregate:
                raise FieldError('Aggregate functions are not allowed in this query')
        elif hasattr(val, 'prepare_database_save'):
            if field.remote_field:
                val = field.get_db_prep_save(val.prepare_database_save(field), connection=self.connection)
            else:
                raise TypeError(('Tried to update field %s with a model instance, %r. Use a value compatible with %s.' % (field, val, field.__class__.__name__)))
        else:
            val = field.get_db_prep_save(val, connection=self.connection)
        if hasattr(field, 'get_placeholder'):
            placeholder = field.get_placeholder(val, self, self.connection)
        else:
            placeholder = '%s'
        name = field.column
        if hasattr(val, 'as_sql'):
            (sql, params) = self.compile(val)
            values.append(('%s = %s' % (qn(name), sql)))
            update_params.extend(params)
        elif (val is not None):
            values.append(('%s = %s' % (qn(name), placeholder)))
            update_params.append(val)
        else:
            values.append(('%s = NULL' % qn(name)))
    if (not values):
        return ('', ())
    result.append(', '.join(values))
    (where, params) = self.compile(self.query.where)
    if where:
        result.append(('WHERE %s' % where))
    return (' '.join(result), tuple((update_params + params)))
Creates the SQL for this query. Returns the SQL string and list of
parameters.
def as_sql(self):
    '\n        Creates the SQL for this query. Returns the SQL string and list of\n        parameters.\n        '
    self.pre_sql_setup()
    if (not self.query.values):
        return (, ())
    table = self.query.tables[0]
    qn = self.quote_name_unless_alias
    result = [('UPDATE %s' % qn(table))]
    result.append('SET')
    (values, update_params) = ([], [])
    for (field, model, val) in self.query.values:
        if hasattr(val, 'resolve_expression'):
            val = val.resolve_expression(self.query, allow_joins=False, for_save=True)
            if val.contains_aggregate:
                raise FieldError('Aggregate functions are not allowed in this query')
        elif hasattr(val, 'prepare_database_save'):
            if field.remote_field:
                val = field.get_db_prep_save(val.prepare_database_save(field), connection=self.connection)
            else:
                raise TypeError(('Tried to update field %s with a model instance, %r. Use a value compatible with %s.' % (field, val, field.__class__.__name__)))
        else:
            val = field.get_db_prep_save(val, connection=self.connection)
        if hasattr(field, 'get_placeholder'):
            placeholder = field.get_placeholder(val, self, self.connection)
        else:
            placeholder = '%s'
        name = field.column
        if hasattr(val, 'as_sql'):
            (sql, params) = self.compile(val)
            values.append(('%s = %s' % (qn(name), sql)))
            update_params.extend(params)
        elif (val is not None):
            values.append(('%s = %s' % (qn(name), placeholder)))
            update_params.append(val)
        else:
            values.append(('%s = NULL' % qn(name)))
    if (not values):
        return (, ())
    result.append(', '.join(values))
    (where, params) = self.compile(self.query.where)
    if where:
        result.append(('WHERE %s' % where))
    return (' '.join(result), tuple((update_params + params)))