Open egonelbre opened 2 months ago
After looking at the code, the implementation might be somewhat difficult due to how database/sql works.
However, one approach would be. First make *rows.Next
return []byte
instead of spanner.NullJSON
-- this makes sure that it can be scanned into []byte
and json.RawMessage
. Before that, however implement Scan
method for spanner.NullJSON
, this will make sure that previous code scanning into spanner.NullJSON
will continue to work.
Is your feature request related to a problem? Please describe.
Currently it's not possible to scan the JSON column into
[]byte
orjson.RawMessage
. This means that there's either going to be an additional unnecessary roundtrip due tospanner.NullJSON
.Small example:
Fails with:
Describe the solution you'd like
Support scanning into
json.RawMessage
,[]byte
.It probably would be useful to support scanning directly into
spanner.GenericColumnValue
as well -- letting the user take control over therows.Next
logic.Describe alternatives you've considered
It would be possible the make the query convert the json to a bytes value, which would complicate the queries themselves.