I have a table with a JSONB typed column props. This is the query I use to extract a property from that column for each row:
var parentIds []string
err := db.
WithNamedArg("ProdIdColName", bun.Ident("productId")).
NewSelect().
Model((*models.Product)(nil)).
ColumnExpr("?TableAlias.props->>? AS ?ProdIdColName", "parentId").
Limit(100).
Scan(context.TODO(), &parentIds)
That gives me the following error though:
{
"errorMessage": "sql: Scan error on column index 0, name \"productId\": invalid character '-' after top-level value",
"errorType": "wrapError",
"stackTrace": [...]
}
There seems to be an issue, that the string value of productId is regarded and attempted to be parsed as JSON. I am not sure, how I could fix/circumvent this. Can anyone point me into the right direction?
This issue has been automatically marked as stale because it has not had activity in the last 30 days. If there is no update within the next 7 days, this issue will be closed.
I have a table with a JSONB typed column
props
. This is the query I use to extract a property from that column for each row:That gives me the following error though:
There seems to be an issue, that the string value of
productId
is regarded and attempted to be parsed as JSON. I am not sure, how I could fix/circumvent this. Can anyone point me into the right direction?