Closed disq closed 6 months ago
Fixed in https://github.com/marcboeker/go-duckdb/pull/171, using string
func TestAppenderJSON(t *testing.T) {
connector, con, appender := prepareAppender(t, `SET autoinstall_known_extensions=1; SET autoload_known_extensions=1; CREATE TABLE test (data json)`)
defer con.Close()
defer connector.Close()
data := `{"key": "value"}`
err := appender.AppendRow(data)
require.NoError(t, err)
err = appender.Close()
require.NoError(t, err)
// Verify results.
db := sql.OpenDB(connector)
res, err := db.QueryContext(
context.Background(),
`SELECT data FROM test`,
)
require.NoError(t, err)
defer res.Close()
i := 0
for res.Next() {
var b string
err = res.Scan(
&b,
)
require.NoError(t, err)
require.Equal(t, data, b)
i++
}
require.Equal(t, 1, i)
}
Repro like this (test code mostly copied from other tests)
If replaced with
json.RawMessage
, then the[]uint8
block gets confused:with *json.RawMessage: