mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve task date handling to prevent errors
Update task storage logic to correctly format and handle date values for PostgreSQL, preventing potential 500 errors caused by type mismatches and incorrect date parsing. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cc2d271b-82f0-4d6a-9302-a0b067ffb429 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cc2d271b-82f0-4d6a-9302-a0b067ffb429/U0y2tJ3
This commit is contained in:
1 parent
24b7d67745
commit
90480201ee
2 files changed
+21
-3
No files matched your search
+21
-3
@@ -1724,16 +1724,34 @@ export class DatabaseStorage implements IStorage {
|
||||
if (taskData.priority !== undefined) cleanData.priority = taskData.priority;
|
||||
if (taskData.status !== undefined) cleanData.status = taskData.status;
|
||||
if (taskData.assignedTo !== undefined) cleanData.assignedTo = taskData.assignedTo;
|
||||
|
||||
// Gestion spéciale des dates selon les types PostgreSQL
|
||||
if (taskData.startDate !== undefined) {
|
||||
cleanData.startDate = taskData.startDate === '' || taskData.startDate === null ? null : taskData.startDate;
|
||||
if (taskData.startDate === '' || taskData.startDate === null) {
|
||||
cleanData.startDate = null;
|
||||
} else {
|
||||
// start_date est un timestamp en PostgreSQL - on peut passer une date
|
||||
cleanData.startDate = new Date(taskData.startDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (taskData.dueDate !== undefined) {
|
||||
cleanData.dueDate = taskData.dueDate === '' || taskData.dueDate === null ? null : taskData.dueDate;
|
||||
if (taskData.dueDate === '' || taskData.dueDate === null) {
|
||||
cleanData.dueDate = null;
|
||||
} else {
|
||||
// due_date est un date en PostgreSQL - on passe la chaîne directement
|
||||
cleanData.dueDate = taskData.dueDate;
|
||||
}
|
||||
}
|
||||
|
||||
cleanData.updatedAt = new Date();
|
||||
|
||||
console.log('🧹 Cleaned data for database update:', cleanData);
|
||||
console.log('🧹 Cleaned data for database update:', {
|
||||
...cleanData,
|
||||
startDateType: cleanData.startDate ? typeof cleanData.startDate : 'null',
|
||||
dueDateType: cleanData.dueDate ? typeof cleanData.dueDate : 'null',
|
||||
startDateIsDate: cleanData.startDate instanceof Date,
|
||||
});
|
||||
|
||||
try {
|
||||
const [task] = await db
|
||||
|
||||
Reference in new issue
Block a user