feat(pgrtl): jsonb/json 컬럼을 JSON 텍스트로 읽기 (map/slice → json.Marshal)
goToHbValue 가 decoded map/slice 를 %v 대신 JSON 으로 직렬화 — jsonb 를 ::text 캐스트 없이 SELECT * 해도 PRG 에서 hb_jsonDecode 가능. 기존 ::text 경로와 일관. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ package pgrtl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -283,6 +284,12 @@ func goToHbValue(g interface{}) hbrt.Value {
|
||||
return hbrt.MakeDouble(v, 0, 0)
|
||||
case time.Time:
|
||||
return hbrt.MakeString(v.Format(time.RFC3339))
|
||||
case map[string]interface{}, []interface{}:
|
||||
// jsonb/json columns arrive as decoded maps/slices — render as JSON
|
||||
// text (matches the `col::text` read convention; callers hb_jsonDecode).
|
||||
if b, err := json.Marshal(v); err == nil {
|
||||
return hbrt.MakeString(string(b))
|
||||
}
|
||||
}
|
||||
return hbrt.MakeString(fmt.Sprintf("%v", g))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user