'Postgresql argument placeholder in jsonpath expression

I try to pass argument $1 to jsonpath-expression:

SELECT 1 FROM %s.orders AS O WHERE order_info @? '$.items[*] ? (@.ProductID == $1)' 

but it doesn't work. Postgresql is saying:

pq: got 1 parameters but the statement requires 0

I tried to concat jsonpath-expression:

SELECT 1 FROM %s.orders AS O WHERE order_info @? '$.items[*] ? (@.ProductID == ' || $1 || ')' 

But it also doesn't work. I use sql Golang package and lib/pq driver.

How I can pass argument to jsonpath expression?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source