本文整理汇总了Python中cassandra.cqlengine.statements.DeleteStatement.add_field方法的典型用法代码示例。如果您正苦于以下问题:Python DeleteStatement.add_field方法的具体用法?Python DeleteStatement.add_field怎么用?Python DeleteStatement.add_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cassandra.cqlengine.statements.DeleteStatement
的用法示例。
在下文中一共展示了DeleteStatement.add_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _delete_null_columns
# 需要导入模块: from cassandra.cqlengine.statements import DeleteStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.DeleteStatement import add_field [as 别名]
def _delete_null_columns(self):
"""
executes a delete query to remove columns that have changed to null
"""
ds = DeleteStatement(self.column_family_name, if_exists=self._if_exists)
deleted_fields = False
for _, v in self.instance._values.items():
col = v.column
if v.deleted:
ds.add_field(col.db_field_name)
deleted_fields = True
elif isinstance(col, columns.Map):
uc = MapDeleteClause(col.db_field_name, v.value, v.previous_value)
if uc.get_context_size() > 0:
ds.add_field(uc)
deleted_fields = True
if deleted_fields:
for name, col in self.model._primary_keys.items():
ds.add_where_clause(WhereClause(
col.db_field_name,
EqualsOperator(),
col.to_database(getattr(self.instance, name))
))
self._execute(ds)
示例2: test_context_update
# 需要导入模块: from cassandra.cqlengine.statements import DeleteStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.DeleteStatement import add_field [as 别名]
def test_context_update(self):
ds = DeleteStatement('table', None)
ds.add_field(MapDeleteClause('d', {1: 2}, {1: 2, 3: 4}))
ds.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
ds.update_context_id(7)
self.assertEqual(six.text_type(ds), 'DELETE "d"[%(8)s] FROM table WHERE "a" = %(7)s')
self.assertEqual(ds.get_context(), {'7': 'b', '8': 3})