Ejemplo n.º 1
0
    def _add_field(
        self,
        model,
        field,
        column_family=None
    ):
        if None is column_family:
            column_family = get_column_family(
                self.connection,
                model
            )

        db_field = (
            field.db_column
            if field.db_column
            else field.column
        )
        cql_field_type = internal_type_to_column_map[field.get_internal_type()]
        cql_field = cql_field_type(
            primary_key=field.primary_key,
            index=field.db_index,
            db_field=db_field,
            required=not field.blank
        )
        setattr(column_family, db_field, cql_field)
        column_family._columns[db_field] = cql_field

        CqlColumnFamilyMetaClass.update_column_family(column_family)
        return column_family
Ejemplo n.º 2
0
    def _remove_field(
        self,
        model,
        field,
        column_family=None
    ):
        if None is column_family:
            column_family = get_column_family(
                self.connection,
                model
            )

        delattr(column_family, field.name)
        db_field = (
            field.db_column
            if field.db_column
            else field.column
        )
        del column_family._columns[db_field]

        CqlColumnFamilyMetaClass.update_column_family(column_family)
        return column_family