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')) {