From d87dfa439c02b07138015a34e4e897b7ef0bf2a2 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Sat, 26 Jul 2025 17:07:57 +0400 Subject: [PATCH] Fix error when mapping already exist Signed-off-by: Bryan Frimin --- pkg/coredata/control_mesure.go | 31 ------------------------------- pkg/probo/control_service.go | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/pkg/coredata/control_mesure.go b/pkg/coredata/control_mesure.go index 72c1f709c..992c01444 100644 --- a/pkg/coredata/control_mesure.go +++ b/pkg/coredata/control_mesure.go @@ -68,37 +68,6 @@ ON CONFLICT (control_id, measure_id) DO NOTHING; return err } -func (cm ControlMeasure) Insert( - ctx context.Context, - conn pg.Conn, - scope Scoper, -) error { - q := ` -INSERT INTO - controls_measures ( - control_id, - measure_id, - tenant_id, - created_at - ) -VALUES ( - @control_id, - @measure_id, - @tenant_id, - @created_at -); -` - - args := pgx.StrictNamedArgs{ - "control_id": cm.ControlID, - "measure_id": cm.MeasureID, - "tenant_id": scope.GetTenantID(), - "created_at": cm.CreatedAt, - } - _, err := conn.Exec(ctx, q, args) - return err -} - func (cm ControlMeasure) Delete( ctx context.Context, conn pg.Conn, diff --git a/pkg/probo/control_service.go b/pkg/probo/control_service.go index 27ffeb5d3..c25a3393d 100644 --- a/pkg/probo/control_service.go +++ b/pkg/probo/control_service.go @@ -370,7 +370,7 @@ func (s ControlService) CreateMeasureMapping( return fmt.Errorf("cannot load measure: %w", err) } - return controlMeasure.Insert(ctx, conn, s.svc.scope) + return controlMeasure.Upsert(ctx, conn, s.svc.scope) }, )