From af7cb6a299a767e2b6f31c3f60576a8b153efefb Mon Sep 17 00:00:00 2001 From: stonezdj Date: Tue, 4 Jun 2024 14:39:19 +0800 Subject: [PATCH] Adjust the query by UUID sql so that it can use the idx_task_extra_attrs_report_uuids fixes #20505 Signed-off-by: stonezdj --- src/pkg/task/dao/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkg/task/dao/task.go b/src/pkg/task/dao/task.go index 17773856189..b42781c17a9 100644 --- a/src/pkg/task/dao/task.go +++ b/src/pkg/task/dao/task.go @@ -114,8 +114,8 @@ func (t *taskDAO) ListScanTasksByReportUUID(ctx context.Context, uuid string) ([ } var tasks []*Task - param := fmt.Sprintf(`{"report_uuids":["%s"]}`, uuid) - sql := `SELECT * FROM task WHERE extra_attrs::jsonb @> cast( ? as jsonb )` + param := fmt.Sprintf(`"%s"`, uuid) + sql := `SELECT * FROM task WHERE extra_attrs::jsonb -> 'report_uuids' @> ?` _, err = ormer.Raw(sql, param).QueryRows(&tasks) if err != nil { return nil, err