Spaces:
Running
Running
Commit ·
8b1a825
1
Parent(s): 46fc486
fix: resolve foreign key constraint error when saving edges
Browse filesFiles changed (2)
108 unmodified lines109110111112113114115116117118119108 unmodified lines}}// 4. Update or Create Edgesforeach (var edge in incomingEdges){// Only create edge if it wasn't deleted (i.e. not connected to a deleted node)if (deletedNodeIds.Contains(edge.FromNodeId) || deletedNodeIds.Contains(edge.ToNodeId)){continue;}108 unmodified lines109110111112113114115116117118119120121108 unmodified lines}}var incomingNodeIds = incomingNodes.Select(n => n.Id).ToHashSet();// 4. Update or Create Edgesforeach (var edge in incomingEdges){// Only create/update edge if both FromNode and ToNode exist in the incoming nodes listif (!incomingNodeIds.Contains(edge.FromNodeId) || !incomingNodeIds.Contains(edge.ToNodeId)){continue;}
123456789101112131415import sqlite3conn = sqlite3.connect('taskflow.db')cursor = conn.cursor()print("--- All TaskNodes ---")nodes = cursor.execute("SELECT * FROM TaskNodes").fetchall()for n in nodes:print(n)print("\n--- All Edges ---")edges = cursor.execute("SELECT * FROM Edges").fetchall()for e in edges:print(e)conn.close()123456789101112131415161718192021222324252627282930import sqlite3def inspect():conn = sqlite3.connect('taskflow.db')cursor = conn.cursor()print("=== Table Schemas ===")tables = cursor.execute("SELECT name, sql FROM sqlite_master WHERE type='table'").fetchall()for name, sql in tables:print(f"Table: {name}")print(sql)print("-" * 50)print("\n=== Foreign Key Check ===")try:# PRAGMA foreign_key_check lists all foreign key violationsviolations = cursor.execute("PRAGMA foreign_key_check").fetchall()if violations:print("Found foreign key violations:")for v in violations:print(f"Table: {v[0]}, RowId: {v[1]}, Target Table: {v[2]}, Fk Index: {v[3]}")else:print("No foreign key violations in the current database.")except Exception as e:print(f"Error checking foreign keys: {e}")conn.close()if __name__ == '__main__':inspect()
FlowAPI.Infrastructure/Repositories/GraphRepository.cs+4-2
FlowAPI/inspect_db.py+26-11