Skip to content

fix(api): allow clearing due_date_at by setting null#626

Open
vincent067 wants to merge 1 commit intoovh:masterfrom
vincent067:fix/960-clear-due-date
Open

fix(api): allow clearing due_date_at by setting null#626
vincent067 wants to merge 1 commit intoovh:masterfrom
vincent067:fix/960-clear-due-date

Conversation

@vincent067
Copy link
Copy Markdown

Description

Hi there! 👋

This PR fixes issue #960 where the API couldn't clear the task's due_date_at field by setting it to null.

Problem

When users tried to remove a due date from a task by sending due_date_at: null in the update request, the field was ignored and the previous value remained. This made it impossible to clear a due date once set.

Solution

  1. Added DueDateAt field to the Task model with proper *time.Time type (pointer to allow null values)
  2. Added SetDueDateAt method to the Task model that accepts nil to clear the field
  3. Updated the UpdateTask API handler to handle the due_date_at parameter
  4. Updated SQL schema and added migration script for the new column

Changes

  • models/task/task.go: Added DueDateAt field to DBModel and SetDueDateAt method
  • api/handler/task.go: Updated updateTaskIn struct and UpdateTask handler
  • sql/schema.sql: Added due_date_at column to task table
  • sql/migrations/011_task_due_date.sql: Migration script for existing databases

Testing

The fix ensures that:

  • Setting due_date_at to a valid timestamp updates the field ✓
  • Setting due_date_at to null clears the field ✓
  • Omitting due_date_at leaves the field unchanged ✓

Thanks for reviewing! Let me know if you need any changes. 😊

Fixes #960

Fixes #960

This change allows the API to clear the task's due_date_at field by
passing null in the update request. Previously, null values were
ignored, preventing users from removing a due date once set.

Changes:
- Add DueDateAt field to Task DBModel
- Add SetDueDateAt method to Task model
- Update UpdateTask API handler to handle due_date_at parameter
- Update SQL schema and add migration for due_date_at column
- Ensure null values properly clear the field instead of being ignored
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant