def save(self):
        """
        Creates / updates a row.
        This is a blind insert call.
        All validation and cleaning needs to happen
        prior to calling this.
        """
        if self.instance is None:
            raise CQLEngineException("DML Query intance attribute is None")
        assert type(self.instance) == self.model

        nulled_fields = set()
        if self.instance._has_counter or self.instance._can_update():
            if self.instance._has_counter:
                warn("'create' and 'save' actions on Counters are deprecated. It will be disallowed in 4.0. "
                    "Use the 'update' mechanism instead.", DeprecationWarning)
            return self.update()
        else:
            insert = InsertStatement(self.column_family_name, ttl=self._ttl, timestamp=self._timestamp, if_not_exists=self._if_not_exists)
            static_save_only = False if len(self.instance._clustering_keys) == 0 else True
            for name, col in self.instance._clustering_keys.items():
                static_save_only = static_save_only and col._val_is_null(getattr(self.instance, name, None))
            for name, col in self.instance._columns.items():
                if static_save_only and not col.static and not col.partition_key:
                    continue
                val = getattr(self.instance, name, None)
                if col._val_is_null(val):
                    if self.instance._values[name].changed:
                        nulled_fields.add(col.db_field_name)
                    continue
                if col.has_default and not self.instance._values[name].changed:
                    # Ensure default columns included in a save() are marked as explicit, to get them *persisted* properly
                    self.instance._values[name].explicit = True
                insert.add_assignment(col, getattr(self.instance, name, None))

        # skip query execution if it's empty
        # caused by pointless update queries
        if not insert.is_empty:
            self._execute(insert)
        # delete any nulled columns
        if not static_save_only:
            self._delete_null_columns()
def save ( self ) : if self . instance is None : raise CQLEngineException ( "DML Query intance attribute is None" ) assert type ( self . instance ) == self . model nulled_fields = set ( ) if self . instance . _has_counter or self . instance . _can_update ( ) : if self . instance . _has_counter : warn ( "'create' and 'save' actions on Counters are deprecated. It will be disallowed in 4.0. " "Use the 'update' mechanism instead." , DeprecationWarning ) return self . update ( ) else : insert = InsertStatement ( self . column_family_name , ttl = self . _ttl , timestamp = self . _timestamp , if_not_exists = self . _if_not_exists ) static_save_only = False if len ( self . instance . _clustering_keys ) == 0 else True for name , col in self . instance . _clustering_keys . items ( ) : static_save_only = static_save_only and col . _val_is_null ( getattr ( self . instance , name , None ) ) for name , col in self . instance . _columns . items ( ) : if static_save_only and not col . static and not col . partition_key : continue val = getattr ( self . instance , name , None ) if col . _val_is_null ( val ) : if self . instance . _values [ name ] . changed : nulled_fields . add ( col . db_field_name ) continue if col . has_default and not self . instance . _values [ name ] . changed : self . instance . _values [ name ] . explicit = True insert . add_assignment ( col , getattr ( self . instance , name , None ) ) if not insert . is_empty : self . _execute ( insert ) if not static_save_only : self . _delete_null_columns ( )
Creates / updates a row.
        This is a blind insert call.
        All validation and cleaning needs to happen
        prior to calling this.