-
Notifications
You must be signed in to change notification settings - Fork 223
Open
Description
Describe the bug
json.RawMessage currently gets encoded as byte list when using as value.
An example is provided below, where the content of a field with type json.RawMessage is used. The expected output would be correct JSON as with []byte.
To Reproduce
type MyType struct {
ContentWithJSONRawMessage json.RawMessage
ContentWithByteSlice []byte
}
func main() {
content := []byte(`{"hello":"world"}`)
s := MyType{
ContentWithJSONRawMessage: content,
ContentWithByteSlice: content,
}
q, _, err := goqu.Insert(goqu.T("my_table")).Rows(goqu.Record{
"content_with_json_raw_message": s.ContentWithJSONRawMessage,
"content_with_byte_slice": s.ContentWithByteSlice,
}).ToSQL()
if err != nil {
panic(err)
}
fmt.Println(q)
}Output:
INSERT INTO "my_table" ("content_with_byte_slice", "content_with_json_raw_message") VALUES ('{"hello":"world"}', (123, 34, 104, 101, 108, 108, 111, 34, 58, 34, 119, 111, 114, 108, 100, 34, 125))
Expected behavior
Both values should be correct JSON as with []byte.
Dialect:
- postgres
- mysql
- sqlite3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels