'Performs an update on the row selected by the queryset. Include values to update in the
update like so:
.. code-block:: python
Model.objects(key=n).update(value=\'x\')
Passing in updates for columns which are not part of the model will raise a ValidationError.
Per column validation will be performed, but instance level validation will not
(i.e., `Model.validate` is not called).  This is sometimes referred to as a blind update.
For example:
.. code-block:: python
class User(Model):
id = Integer(primary_key=True)
name = Text()
setup(["localhost"], "test")
sync_table(User)
u = User.create(id=1, name="jon")
User.objects(id=1).update(name="Steve")
# sets name to null
User.objects(id=1).update(name=None)
Also supported is blindly adding and removing elements from container columns,
without loading a model instance from Cassandra.
Using the syntax `.update(column_name={x, y, z})` will overwrite the contents of the container, like updating a
non container column. However, adding `__<operation>` to the end of the keyword arg, makes the update call add
or remove items from the collection, without overwriting then entire column.
Given the model below, here are the operations that can be performed on the different container columns:
.. code-block:: python
class Row(Model):
row_id      = columns.Integer(primary_key=True)
set_column  = columns.Set(Integer)
list_column = columns.List(Integer)
map_column  = columns.Map(Integer, Integer)
:class:`~cqlengine.columns.Set`
- `add`: adds the elements of the given set to the column
- `remove`: removes the elements of the given set to the column
.. code-block:: python
# add elements to a set
Row.objects(row_id=5).update(set_column__add={6})
# remove elements to a set
Row.objects(row_id=5).update(set_column__remove={4})
:class:`~cqlengine.columns.List`
- `append`: appends the elements of the given list to the end of the column
- `prepend`: prepends the elements of the given list to the beginning of the column
.. code-block:: python
# append items to a list
Row.objects(row_id=5).update(list_column__append=[6, 7])
# prepend items to a list
Row.objects(row_id=5).update(list_column__prepend=[1, 2])
:class:`~cqlengine.columns.Map`
- `update`: adds the given keys/values to the columns, creating new entries if they didn\'t exist, and overwriting old ones if they did
.. code-block:: python
# add items to a map
Row.objects(row_id=5).update(map_column__update={1: 2, 3: 4})
# remove items from a map
Row.objects(row_id=5).update(map_column__remove={1, 2})'

def update(self, **values):

    if (not values):
        return
    nulled_columns = set()
    updated_columns = set()
    us = UpdateStatement(self.column_family_name, where=self._where, ttl=self._ttl, timestamp=self._timestamp, conditionals=self._conditional, if_exists=self._if_exists)
    for (name, val) in values.items():
        (col_name, col_op) = self._parse_filter_arg(name)
        col = self.model._columns.get(col_name)
        if (col is None):
            raise ValidationError('{0}.{1}    has    no    column    named:    {2}'.format(self.__module__, self.model.__name__, col_name))
        if col.is_primary_key:
            raise ValidationError("Cannot    apply    update    to    primary    key    '{0}'    for    {1}.{2}".format(col_name, self.__module__, self.model.__name__))
        if ((col_op == 'remove') and isinstance(col, columns.Map)):
            if (not isinstance(val, set)):
                raise ValidationError("Cannot    apply    update    operation    '{0}'    on    column    '{1}'    with    value    '{2}'.    A    set    is    required.".format(col_op, col_name, val))
            val = {v: None for v in val}
        else:
            val = col.validate(val)
        if (val is None):
            nulled_columns.add(col_name)
            continue
        us.add_update(col, val, operation=col_op)
        updated_columns.add(col_name)
    if us.assignments:
        self._execute(us)
    if nulled_columns:
        delete_conditional = ([condition for condition in self._conditional if (condition.field not in updated_columns)] if self._conditional else None)
        ds = DeleteStatement(self.column_family_name, fields=nulled_columns, where=self._where, conditionals=delete_conditional, if_exists=self._if_exists)
        self._execute(ds)
