Encode json values implicitly in the sql queries according the golang json package spec.

This commit is contained in:
go-jet 2025-03-08 19:01:37 +01:00
parent 9616bb5cfe
commit 17646ca99c
54 changed files with 1446 additions and 744 deletions

View file

@ -3,9 +3,9 @@ package qrm
import (
"context"
"database/sql"
"encoding/json"
"errors"
"fmt"
"github.com/go-jet/jet/v2/internal/3rdparty/json"
"github.com/go-jet/jet/v2/internal/utils/must"
"reflect"
)
@ -67,8 +67,8 @@ func QueryJsonArr(ctx context.Context, db Queryable, query string, args []interf
return queryJson(ctx, db, query, args, destPtr)
}
var jsonDestObjErr = "jet: destination has to be a pointer to struct or pointer to map[string]any"
var jsonDestArrErr = "jet: destination has to be a pointer to slice of struct or pointer to []map[string]any"
var jsonDestObjErr = "jet: SELECT_JSON_OBJ destination has to be a pointer to struct or pointer to map[string]any"
var jsonDestArrErr = "jet: SELECT_JSON_ARR destination has to be a pointer to slice of struct or pointer to []map[string]any"
func queryJson(ctx context.Context, db Queryable, query string, args []interface{}, destPtr interface{}) (rowsProcessed int64, err error) {
must.BeInitializedPtr(db, "jet: db is nil")