From 6f2f3669a36619464db572e19f20851fb2a21f44 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Nov 2025 16:16:10 +0000 Subject: [PATCH] fix: revert INTEGER fields to use 0/1 instead of boolean Corrected previous commit - some fields in the schema are INTEGER, not BOOLEAN: - notes.priority is INTEGER (not BOOLEAN) - needs 0/1 - global_todos.in_progress is INTEGER (not BOOLEAN) - needs 0/1 All other fields (archived, completed, etc.) correctly use BOOLEAN and were properly fixed in the previous commit. This resolves the 500 error when trying to set INTEGER fields with boolean values. --- routes/notes.routes.js | 2 +- routes/todos.routes.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/notes.routes.js b/routes/notes.routes.js index 941a2f3..422373b 100644 --- a/routes/notes.routes.js +++ b/routes/notes.routes.js @@ -972,7 +972,7 @@ router.patch('/:id/priority', async (req, res) => { return res.status(404).json({ error: 'Note non trouvée' }); } - await runQuery('UPDATE notes SET priority = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2', [priority, req.params.id]); // BOOLEAN instead of 0/1 + await runQuery('UPDATE notes SET priority = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2', [priority ? 1 : 0, req.params.id]); // notes.priority is INTEGER not BOOLEAN logger.info(`Priorité de la note ${req.params.id} modifiée: ${priority}`); res.json({ message: 'Priorité modifiée avec succès', priority }); diff --git a/routes/todos.routes.js b/routes/todos.routes.js index 2c0eb86..726c63d 100644 --- a/routes/todos.routes.js +++ b/routes/todos.routes.js @@ -150,7 +150,7 @@ router.put('/:id', if (in_progress !== undefined) { paramCount++; updates.push(`in_progress = $${paramCount}`); - params.push(in_progress); // BOOLEAN instead of 0/1 + params.push(in_progress ? 1 : 0); // global_todos.in_progress is INTEGER not BOOLEAN } if (updates.length > 0) { @@ -240,12 +240,12 @@ router.patch('/:id/in-progress', async (req, res) => { return res.status(404).json({ error: 'Todo non trouvé' }); } - const newInProgress = !todo.in_progress; // BOOLEAN instead of 0/1 + const newInProgress = todo.in_progress ? 0 : 1; // global_todos.in_progress is INTEGER not BOOLEAN await runQuery('UPDATE global_todos SET in_progress = $1 WHERE id = $2', [newInProgress, req.params.id]); logger.info(`Todo global ${newInProgress ? 'marqué en cours' : 'démarqué en cours'} (ID: ${req.params.id}) par ${req.user.username}`); - res.json({ message: 'Statut en cours modifié avec succès', in_progress: newInProgress }); + res.json({ message: 'Statut en cours modifié avec succès', in_progress: newInProgress === 1 }); } catch (inProgressError) { // Si le champ in_progress n'existe pas encore if (inProgressError.message && inProgressError.message.includes('in_progress')) {