I am having trouble using jsonb in a simple scenario. I am running postgres (PostgreSQL) 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1) and have the following schema and query
# schema.sql
create table orders (
id INT not null GENERATED ALWAYS AS IDENTITY ,
file_number text not null,
order_file jsonb NOT NULL,
PRIMARY KEY(id)
);
# query.sql
-- name: InsertOrder :one
insert into orders (file_number, order_file) values($1, $2) RETURNING *;
# main.go
insertStruct := pgdb.InsertOrderParams{}
insertStruct.OrderFile = json.RawMessage(json_marshalled)
order, err := s.DataService.InsertOrder(context.Background(), insertStruct)
I have included the relevant parts above. I tried to insert a json object and I get the following error
cannot InsertOrder err: | error: sql: Scan error on column index 11, name "order_file": unsupported Scan, storing driver.Value type string into type *json.RawMessage
The record does get inserted, but I think when the data is being read back, there is an incompatibility with the sql library? I would appreciate any guidance.