From ce228dd68db6971ce42aa25111b3dfddf3309078 Mon Sep 17 00:00:00 2001 From: CharlesKWON Date: Tue, 16 Jun 2026 14:49:07 +0900 Subject: [PATCH] =?UTF-8?q?feat(pgrtl):=20jsonb/json=20=EC=BB=AC=EB=9F=BC?= =?UTF-8?q?=EC=9D=84=20JSON=20=ED=85=8D=EC=8A=A4=ED=8A=B8=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=BD=EA=B8=B0=20(map/slice=20=E2=86=92=20json.Marshal)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit goToHbValue 가 decoded map/slice 를 %v 대신 JSON 으로 직렬화 — jsonb 를 ::text 캐스트 없이 SELECT * 해도 PRG 에서 hb_jsonDecode 가능. 기존 ::text 경로와 일관. Co-Authored-By: Claude Opus 4.8 (1M context) --- hbrtl_ext/pgrtl/pg.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hbrtl_ext/pgrtl/pg.go b/hbrtl_ext/pgrtl/pg.go index bf10d8a..ae2fa87 100644 --- a/hbrtl_ext/pgrtl/pg.go +++ b/hbrtl_ext/pgrtl/pg.go @@ -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)) }