From 0dc74b503506b8fa6337b1943dc90ccc54882fa5 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Sat, 25 Apr 2026 02:23:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A4=BE=E5=8C=BA?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E7=A9=BA=E6=95=B0=E7=BB=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/community/rpc/internal/logic/helpers.go | 2 +- pkg/types/TextArray.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/community/rpc/internal/logic/helpers.go b/app/community/rpc/internal/logic/helpers.go index d134634..09d672f 100644 --- a/app/community/rpc/internal/logic/helpers.go +++ b/app/community/rpc/internal/logic/helpers.go @@ -10,7 +10,7 @@ import ( func toTextArray(s []string) types.TextArray { if len(s) == 0 { - return types.TextArray{Valid: true} + return types.TextArray{Elements: []string{}, Valid: true} } return types.TextArray{ Elements: s, diff --git a/pkg/types/TextArray.go b/pkg/types/TextArray.go index d34707c..3bedd2e 100644 --- a/pkg/types/TextArray.go +++ b/pkg/types/TextArray.go @@ -13,6 +13,13 @@ type TextArray pgtype.Array[string] func (s *TextArray) Scan(src any) error { logx.Infof("scan src=%+v", src) + if src == nil { + s.Elements = []string{} + s.Dims = nil + s.Valid = true + return nil + } + var strSrc string switch v := src.(type) { case string: @@ -37,5 +44,8 @@ func (s *TextArray) Scan(src any) error { } func (s TextArray) Value() (driver.Value, error) { + if s.Elements == nil { + return []string{}, nil + } return s.Elements, nil }