fix: 修复社区帖子空数组处理

This commit is contained in:
zetaloop
2026-04-25 02:23:05 +08:00
parent dc57a61688
commit 0dc74b5035
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -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,
+10
View File
@@ -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
}