From e4700cd2017fe61576295ab8a3b34922a8f750d2 Mon Sep 17 00:00:00 2001 From: Danieldd28 Date: Wed, 11 Feb 2026 02:21:32 +0700 Subject: [PATCH] fix: use explicit SQL column names to prevent schema mismatch errors --- pkg/swarm/memory/sqlite_store.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/swarm/memory/sqlite_store.go b/pkg/swarm/memory/sqlite_store.go index 57d9a8800..af3689ed1 100644 --- a/pkg/swarm/memory/sqlite_store.go +++ b/pkg/swarm/memory/sqlite_store.go @@ -37,7 +37,7 @@ func (s *SQLiteStore) init() error { } func (s *SQLiteStore) CreateSwarm(ctx context.Context, sw *core.Swarm) error { - _, err := s.db.ExecContext(ctx, "INSERT INTO swarms VALUES (?, ?, ?, ?)", sw.ID, sw.Goal, sw.Status, sw.CreatedAt) + _, err := s.db.ExecContext(ctx, "INSERT INTO swarms (id, goal, status, created_at) VALUES (?, ?, ?, ?)", sw.ID, sw.Goal, sw.Status, sw.CreatedAt) return err } @@ -81,12 +81,12 @@ func (s *SQLiteStore) CreateNode(ctx context.Context, n *core.Node) error { if err != nil { return err } - _, err = s.db.ExecContext(ctx, "INSERT INTO nodes VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n.ID, n.SwarmID, n.ParentID, role, n.Task, n.Status, n.Output, stats) + _, err = s.db.ExecContext(ctx, "INSERT INTO nodes (id, swarm_id, parent_id, role, task, status, output, stats) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n.ID, n.SwarmID, n.ParentID, role, n.Task, n.Status, n.Output, stats) return err } func (s *SQLiteStore) GetNode(ctx context.Context, id core.NodeID) (*core.Node, error) { - row := s.db.QueryRowContext(ctx, "SELECT * FROM nodes WHERE id=?", id) + row := s.db.QueryRowContext(ctx, "SELECT id, swarm_id, parent_id, role, task, status, output, stats FROM nodes WHERE id=?", id) var n core.Node var role, stats []byte if err := row.Scan(&n.ID, &n.SwarmID, &n.ParentID, &role, &n.Task, &n.Status, &n.Output, &stats); err != nil { @@ -111,7 +111,7 @@ func (s *SQLiteStore) UpdateNode(ctx context.Context, n *core.Node) error { } func (s *SQLiteStore) GetSwarmNodes(ctx context.Context, id core.SwarmID) ([]*core.Node, error) { - rows, err := s.db.QueryContext(ctx, "SELECT * FROM nodes WHERE swarm_id=?", id) + rows, err := s.db.QueryContext(ctx, "SELECT id, swarm_id, parent_id, role, task, status, output, stats FROM nodes WHERE swarm_id=?", id) if err != nil { return nil, err } @@ -139,7 +139,7 @@ func (s *SQLiteStore) SaveFact(ctx context.Context, f core.Fact) error { if err != nil { return err } - _, err = s.db.ExecContext(ctx, "INSERT INTO facts VALUES (?, ?, ?, ?, ?)", f.SwarmID, f.Content, f.Confidence, f.Source, meta) + _, err = s.db.ExecContext(ctx, "INSERT INTO facts (swarm_id, content, confidence, source, metadata) VALUES (?, ?, ?, ?, ?)", f.SwarmID, f.Content, f.Confidence, f.Source, meta) return err }