Add support for configuring the JSON unmarshal function used when querying SELECT_JSON statements.

This commit is contained in:
go-jet 2025-03-11 13:33:39 +01:00
parent 7ab44bc61c
commit 1db6b12074
6 changed files with 74 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package postgres
import (
"github.com/bytedance/sonic"
"github.com/go-jet/jet/v2/internal/testutils"
. "github.com/go-jet/jet/v2/postgres"
"github.com/go-jet/jet/v2/tests/.gentestdata/jetdb/northwind/model"
@ -110,6 +111,21 @@ func TestNorthwindJoinEverythingJson(t *testing.T) {
testNorthwindJoinEverythingJson(t)
}
func BenchmarkTestNorthwindJoinEverythingSonicJson(b *testing.B) {
useJsonUnmarshalFunc(sonic.Unmarshal, func() {
for i := 0; i < b.N; i++ {
testNorthwindJoinEverythingJson(b)
}
})
}
// uncomment when bug is fixed: https://github.com/bytedance/sonic/issues/774
//func TestNorthwindJoinEverythingJsonSonic(t *testing.T) {
// useJsonUnmarshalFunc(sonic.Unmarshal, func() {
// testNorthwindJoinEverythingJson(t)
// })
//}
func testNorthwindJoinEverythingJson(t require.TestingT) {
stmt := SELECT_JSON_ARR(