I have a problem with correct parsing of JSONB to []string in golang
query := sq.StatementBuilder.
PlaceholderFormat(sq.Dollar).
Select(
...
"logbooks.stages -> logbook_entries.next_stage_id ->> 'employee_position_ids' as employee_position_ids."
).
From("logbook_entries").
Join("logbooks on logbooks.id = logbook_entries.logbook_id and logbooks.current_version=logbook_entries.logbook_version").
...
Later i tried to parse the row into my custom struct
type incompleteEntry struct {
...
EmployeePositionIDs []string
}
for rows.Next() {
var item incompleteEntry
err := rows.Scan(
...
&item.EmployeePositionIDs,
)
if err != nil {
return nil, err
}
}
In result I got the following error message
can't scan into dest[6]: cannot scan text (OID 25) in text format into *[]string
In project I use jackc/pgxpool
and as a query builder squirrel
package