From e7b693c788396336b0ae2f07c2ca8d3fd797936a Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 2 Apr 2026 18:19:23 +0200 Subject: [PATCH] fix(tasks): include tasks with deleted parents in subtask-expanded queries When expand[]=subtasks is used, the LEFT JOIN on task_relations filters out same-project subtasks. If a parent task was deleted, the JOIN produces NULL for parent_tasks.id/project_id, and since NULL != value evaluates to NULL (not TRUE) in SQL, these tasks were incorrectly excluded. Add builder.IsNull{"parent_tasks.id"} to the OR condition so tasks whose parent was deleted are still included in results. --- pkg/models/task_search.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/models/task_search.go b/pkg/models/task_search.go index d4a39197c..07da3f809 100644 --- a/pkg/models/task_search.go +++ b/pkg/models/task_search.go @@ -369,6 +369,7 @@ func (d *dbTaskSearcher) Search(opts *taskSearchOptions) (tasks []*Task, totalCo if expandSubtasks { cond = builder.And(cond, builder.Or( builder.IsNull{"task_relations.id"}, + builder.IsNull{"parent_tasks.id"}, builder.Expr("parent_tasks.project_id != tasks.project_id"), )) }