From 35100f9549633c49b621c7acbf29d756d022292b Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 30 Sep 2024 17:24:51 -0400 Subject: [PATCH] fix: drop graph instead of truncate --- nx_arangodb/classes/graph.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/nx_arangodb/classes/graph.py b/nx_arangodb/classes/graph.py index 42a153c..86414e9 100644 --- a/nx_arangodb/classes/graph.py +++ b/nx_arangodb/classes/graph.py @@ -231,13 +231,21 @@ def __init__( self.__set_arangodb_backend_config(read_parallelism, read_batch_size) if overwrite_graph: - logger.info("Truncating graph collections...") - - for col in self.adb_graph.vertex_collections(): - self.db.collection(col).truncate() - - for col in self.adb_graph.edge_definitions(): - self.db.collection(col["edge_collection"]).truncate() + logger.info("Overwriting graph...") + + properties = self.adb_graph.properties() + self.db.delete_graph(name, drop_collections=True) + self.db.create_graph( + name=name, + edge_definitions=properties["edge_definitions"], + orphan_collections=properties["orphan_collections"], + smart=properties.get("smart"), + disjoint=properties.get("disjoint"), + smart_field=properties.get("smart_field"), + shard_count=properties.get("shard_count"), + replication_factor=properties.get("replication_factor"), + write_concern=properties.get("write_concern"), + ) if isinstance(incoming_graph_data, nx.Graph): self._load_nx_graph(incoming_graph_data, write_batch_size, write_async)