mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-11 17:29:37 +02:00
fix: correct SQL bug in todo creation query
Fixed critical SQL type error in todo creation endpoint that prevented todos from being added to notes. Bug: - Line 417: Used FALSE (boolean) instead of 0 (integer) in COALESCE function - SQL: COALESCE(MAX(position), FALSE) + 1 - This caused a type mismatch error when inserting new todos Fix: - Changed to: COALESCE(MAX(position), 0) + 1 - Now correctly defaults to 0 when no todos exist for a note This fix resolves the issue where adding todos would fail silently or throw database errors.
This commit is contained in:
1 file changed
+1
-1
@@ -414,7 +414,7 @@ router.post('/:id/todos',
|
||||
|
||||
const result = await runQuery(`
|
||||
INSERT INTO note_todos (note_id, text, position)
|
||||
VALUES ($1, $2, (SELECT COALESCE(MAX(position), FALSE) + 1 FROM note_todos WHERE note_id = $3))
|
||||
VALUES ($1, $2, (SELECT COALESCE(MAX(position), 0) + 1 FROM note_todos WHERE note_id = $3))
|
||||
RETURNING *
|
||||
`, [req.params.id, text, req.params.id]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user