MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / _validate_pk

Function _validate_pk

cassandra/cqlengine/management.py:292–305  ·  view source on GitHub ↗
(model, table_meta)

Source from the content-addressed store, hash-verified

290
291
292def _validate_pk(model, table_meta):
293 model_partition = [c.db_field_name for c in model._partition_keys.values()]
294 meta_partition = [c.name for c in table_meta.partition_key]
295 model_clustering = [c.db_field_name for c in model._clustering_keys.values()]
296 meta_clustering = [c.name for c in table_meta.clustering_key]
297
298 if model_partition != meta_partition or model_clustering != meta_clustering:
299 def _pk_string(partition, clustering):
300 return "PRIMARY KEY (({0}){1})".format(', '.join(partition), ', ' + ', '.join(clustering) if clustering else '')
301 raise CQLEngineException("Model {0} PRIMARY KEY composition does not match existing table {1}. "
302 "Model: {2}; Table: {3}. "
303 "Update model or drop the table.".format(model, model.column_family_name(),
304 _pk_string(model_partition, model_clustering),
305 _pk_string(meta_partition, meta_clustering)))
306
307
308def sync_type(ks_name, type_model, connection=None):

Callers 1

_sync_tableFunction · 0.85

Calls 4

CQLEngineExceptionClass · 0.90
_pk_stringFunction · 0.85
valuesMethod · 0.45
column_family_nameMethod · 0.45

Tested by

no test coverage detected