@@ -2,7 +2,6 @@ package main
22
33import (
44 plugin "github.com/Paca-AI/plugin-sdk-go"
5- "github.com/google/uuid"
65)
76
87// ── Item route handlers ───────────────────────────────────────────────────────
@@ -46,17 +45,20 @@ func (p *checklistPlugin) createItem(req *plugin.Request, res *plugin.Response)
4645 nextPos = sc .intVal ("next_pos" )
4746 }
4847
49- id := uuid .New ().String ()
5048 now := nowStr ()
51- _ , err = p .db .Exec (
52- `INSERT INTO task_checklist_items (id, checklist_id, title, is_checked, assignee_id, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ` ,
53- id , checklistID , b .Title , false , nil , nextPos , req .Caller .CallerID , now , now ,
49+ inserted , err : = p .db .Query (
50+ `INSERT INTO task_checklist_items (checklist_id, title, is_checked, assignee_id, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id ` ,
51+ checklistID , b .Title , false , nil , nextPos , req .Caller .CallerID , now , now ,
5452 )
55- if err != nil {
56- p .log .Error ("createItem insert: " + err .Error ())
53+ if err != nil || len (inserted .Rows ) == 0 {
54+ if err != nil {
55+ p .log .Error ("createItem insert: " + err .Error ())
56+ }
5757 res .Error (500 , "failed to create item" )
5858 return
5959 }
60+ idSC := newRowScanner (inserted .Columns , inserted .Rows [0 ])
61+ id := idSC .str ("id" )
6062 item := checklistItem {
6163 ID : id ,
6264 ChecklistID : checklistID ,
0 commit comments