Apply fix, incorrect statement invocation

This commit is contained in:
Cyber MacGeddon 2025-10-06 14:24:05 +01:00
parent 3e23d3c3ed
commit 1c68a955ab

View file

@ -182,6 +182,23 @@ class KnowledgeGraph:
f"SELECT s as x FROM {self.collection_table} WHERE collection = ? AND s = ? AND p = ? AND o = ? LIMIT ?" f"SELECT s as x FROM {self.collection_table} WHERE collection = ? AND s = ? AND p = ? AND o = ? LIMIT ?"
) )
# Delete statements for collection deletion
self.delete_subject_stmt = self.session.prepare(
f"DELETE FROM {self.subject_table} WHERE collection = ? AND s = ? AND p = ? AND o = ?"
)
self.delete_po_stmt = self.session.prepare(
f"DELETE FROM {self.po_table} WHERE collection = ? AND p = ? AND o = ? AND s = ?"
)
self.delete_object_stmt = self.session.prepare(
f"DELETE FROM {self.object_table} WHERE collection = ? AND o = ? AND s = ? AND p = ?"
)
self.delete_collection_stmt = self.session.prepare(
f"DELETE FROM {self.collection_table} WHERE collection = ? AND s = ? AND p = ? AND o = ?"
)
logger.info("Prepared statements initialized for optimal performance (4 tables)") logger.info("Prepared statements initialized for optimal performance (4 tables)")
def insert(self, collection, s, p, o): def insert(self, collection, s, p, o):
@ -304,24 +321,16 @@ class KnowledgeGraph:
s, p, o = row.s, row.p, row.o s, p, o = row.s, row.p, row.o
# Delete from subject table (partition key: collection, s) # Delete from subject table (partition key: collection, s)
batch.add(SimpleStatement( batch.add(self.delete_subject_stmt, (collection, s, p, o))
f"DELETE FROM {self.subject_table} WHERE collection = ? AND s = ? AND p = ? AND o = ?"
), (collection, s, p, o))
# Delete from predicate-object table (partition key: collection, p) # Delete from predicate-object table (partition key: collection, p)
batch.add(SimpleStatement( batch.add(self.delete_po_stmt, (collection, p, o, s))
f"DELETE FROM {self.po_table} WHERE collection = ? AND p = ? AND o = ? AND s = ?"
), (collection, p, o, s))
# Delete from object table (partition key: collection, o) # Delete from object table (partition key: collection, o)
batch.add(SimpleStatement( batch.add(self.delete_object_stmt, (collection, o, s, p))
f"DELETE FROM {self.object_table} WHERE collection = ? AND o = ? AND s = ? AND p = ?"
), (collection, o, s, p))
# Delete from collection table (partition key: collection only) # Delete from collection table (partition key: collection only)
batch.add(SimpleStatement( batch.add(self.delete_collection_stmt, (collection, s, p, o))
f"DELETE FROM {self.collection_table} WHERE collection = ? AND s = ? AND p = ? AND o = ?"
), (collection, s, p, o))
count += 1 count += 1