diff --git a/adapter/postgresql/helper_test.go b/adapter/postgresql/helper_test.go index 04654e71..e553df17 100644 --- a/adapter/postgresql/helper_test.go +++ b/adapter/postgresql/helper_test.go @@ -194,6 +194,7 @@ func (h *Helper) TearUp() error { , integer_array integer[] , string_array text[] , jsonb_map jsonb + , raw_jsonb_map jsonb , integer_array_ptr integer[] , string_array_ptr text[] diff --git a/adapter/postgresql/postgresql_test.go b/adapter/postgresql/postgresql_test.go index 7d3708e5..8431998d 100644 --- a/adapter/postgresql/postgresql_test.go +++ b/adapter/postgresql/postgresql_test.go @@ -25,6 +25,7 @@ import ( "context" "database/sql" "database/sql/driver" + "encoding/json" "fmt" "math/rand" "strings" @@ -229,6 +230,8 @@ func testPostgreSQLTypes(t *testing.T, sess db.Session) { StringArray StringArray `db:"string_array,stringarray"` JSONBMap JSONBMap `db:"jsonb_map"` + RawJSONBMap *json.RawMessage `db:"raw_jsonb_map,omitempty"` + PGTypeInline `db:",inline"` PGTypeAutoInline `db:",inline"` @@ -275,6 +278,7 @@ func testPostgreSQLTypes(t *testing.T, sess db.Session) { integerArrayValue := Int64Array{1, 2, 3, 4} stringArrayValue := StringArray{"a", "b", "c"} jsonbMapValue := JSONBMap{"Hello": "World"} + rawJSONBMap := json.RawMessage(`{"foo": "bar"}`) testValue := "Hello world!" @@ -329,6 +333,9 @@ func testPostgreSQLTypes(t *testing.T, sess db.Session) { AutoJSONBMapInteger: map[string]interface{}{"a": 12.0, "b": 13.0}, }, }, + PGType{ + RawJSONBMap: &rawJSONBMap, + }, PGType{ IntegerValue: integerValue, StringValue: stringValue, diff --git a/internal/sqlbuilder/convert.go b/internal/sqlbuilder/convert.go index 50f344c9..37901f61 100644 --- a/internal/sqlbuilder/convert.go +++ b/internal/sqlbuilder/convert.go @@ -57,7 +57,7 @@ func toInterfaceArguments(value interface{}) (args []interface{}, isSlice bool) // Byte slice gets transformed into a string. if v.Type().Elem().Kind() == reflect.Uint8 { - return []interface{}{string(value.([]byte))}, false + return []interface{}{string(v.Bytes())}, false } total = v.Len()