fix: use explicit SQL column names to prevent schema mismatch errors
This commit is contained in:
parent
5bfea8687a
commit
e4700cd201
1 changed files with 5 additions and 5 deletions
|
|
@ -37,7 +37,7 @@ func (s *SQLiteStore) init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLiteStore) CreateSwarm(ctx context.Context, sw *core.Swarm) 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,12 +81,12 @@ func (s *SQLiteStore) CreateNode(ctx context.Context, n *core.Node) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLiteStore) GetNode(ctx context.Context, id core.NodeID) (*core.Node, error) {
|
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 n core.Node
|
||||||
var role, stats []byte
|
var role, stats []byte
|
||||||
if err := row.Scan(&n.ID, &n.SwarmID, &n.ParentID, &role, &n.Task, &n.Status, &n.Output, &stats); err != nil {
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +139,7 @@ func (s *SQLiteStore) SaveFact(ctx context.Context, f core.Fact) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue