def test_column_name_multiple_partition(self): tm = TableMetadata('ks', 'table') cm = ColumnMetadata(tm, self.name, u'int') tm.columns[cm.name] = cm tm.partition_key.append(cm) cm = ColumnMetadata(tm, self.name + 'x', u'int') tm.columns[cm.name] = cm tm.partition_key.append(cm) tm.export_as_string()
def sync_table(cls, model, keyspaces=[], connections=[]): for connection in connections: assert connection in cls.connections for keyspace in keyspaces: keyspace_metadata = MockCQLEngineContext.get_cluster( connection).metadata.keyspaces.get(keyspace) assert keyspace_metadata is not None primary_keys = [] column_keys = [] for key, value in model._columns.items(): if value.partition_key or value.primary_key: primary_keys.append(key) else: column_keys.append(key) columns = OrderedDict() partition_keys = [] clustering_keys = [] for key in primary_keys + column_keys: value = model._columns[key] meta_data = ColumnMetadata( None, key, value.db_type, is_reversed=(value.clustering_order == 'DESC')) columns[key] = meta_data if value.partition_key: partition_keys.append(meta_data) if value.primary_key: clustering_keys.append(meta_data) MockCluster.database[keyspace][ model._raw_column_family_name()] = defaultdict(lambda: {}) keyspace_metadata.tables[ model._raw_column_family_name()] = TableMetadataV3( keyspace, model._raw_column_family_name(), columns=columns, partition_key=partition_keys, clustering_key=clustering_keys, )
def column(table_metadata, column_name, cql_type, is_static=False, is_reversed=False): return ColumnMetadata(table_metadata, column_name, cql_type)