From 78012c9ac6d026852f27bf6f2b9b397dbbd9a567 Mon Sep 17 00:00:00 2001 From: "stonezdj(Daojun Zhang)" Date: Thu, 6 Jun 2024 15:43:46 +0800 Subject: [PATCH] =?UTF-8?q?[cherry-pick]=20Adjust=20the=20query=20by=20UUI?= =?UTF-8?q?D=20sql=20so=20that=20it=20can=20use=20the=20idx=5Ftask=5Fextra?= =?UTF-8?q?=5Fat=E2=80=A6=20(#20552)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/common/rbac/project/rbac_role.go | 3 --- src/pkg/task/dao/task.go | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/common/rbac/project/rbac_role.go b/src/common/rbac/project/rbac_role.go index fa618b982..a98ccd2e5 100644 --- a/src/common/rbac/project/rbac_role.go +++ b/src/common/rbac/project/rbac_role.go @@ -122,10 +122,7 @@ var ( {Resource: rbac.ResourceMember, Action: rbac.ActionRead}, {Resource: rbac.ResourceMember, Action: rbac.ActionList}, - {Resource: rbac.ResourceMetadata, Action: rbac.ActionCreate}, {Resource: rbac.ResourceMetadata, Action: rbac.ActionRead}, - {Resource: rbac.ResourceMetadata, Action: rbac.ActionUpdate}, - {Resource: rbac.ResourceMetadata, Action: rbac.ActionDelete}, {Resource: rbac.ResourceLog, Action: rbac.ActionList}, diff --git a/src/pkg/task/dao/task.go b/src/pkg/task/dao/task.go index 177738561..b42781c17 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