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.
This commit is contained in:
Claude committed 2025-11-28 16:16:10 +00:00
1 parent 616e257b07
commit 6f2f3669a3
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -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 });
+3 -3
View File
@@ -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')) {