From 942c45a95c7671d91f103b51ef5fafbe6808f7d8 Mon Sep 17 00:00:00 2001 From: Nam Huynh Date: Thu, 19 Aug 2021 15:31:48 +0700 Subject: [PATCH] fix insert and update args --- action_upsert.go | 4 ++-- find_by_device_id.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/action_upsert.go b/action_upsert.go index d5e353e..025c941 100644 --- a/action_upsert.go +++ b/action_upsert.go @@ -102,7 +102,7 @@ func (s Service) Upsert(payload UpsertPayload) { pretty.Println("stm -", stm) pretty.Println("args -", args) - if _, err := s.DB.ExecContext(ctx, stm, args); err != nil { + if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil { logger.Error("devicemngt - Upsert: Create new", logger.LogData{ "payload": payload, "error": err.Error(), @@ -131,7 +131,7 @@ func (s Service) Upsert(payload UpsertPayload) { pretty.Println("stm -", stm) pretty.Println("args -", args) - if _, err := s.DB.ExecContext(ctx, stm, args); err != nil { + if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil { logger.Error("devicemngt - Upsert: Update", logger.LogData{ "payload": payload, "error": err.Error(), diff --git a/find_by_device_id.go b/find_by_device_id.go index 53843ed..70a95c4 100644 --- a/find_by_device_id.go +++ b/find_by_device_id.go @@ -10,7 +10,7 @@ import ( func (s Service) findByDeviceID(ctx context.Context, id string) (result Device) { stm, args, _ := s.Builder.Select("*").From(TableDeviceMngt).Where("device_id = ?", id).ToSql() - if err := s.DB.GetContext(ctx, &result, stm, args...); err != nil { + if err := s.DB.SelectContext(ctx, &result, stm, args...); err != nil { logger.Error("devicemngt - findByDeviceID", logger.LogData{ "device_id": id, "error": err.Error(),