Postgre JSONB ? operator
ashtonian opened this issue · 5 comments
ashtonian commented
trying to use the JSONB?
operator for a JSON contains function and I'm getting a dbr: wrong placeholder count
error. Is there a way to escape the ?
?
Repro:
package main
import "github.com/gocraft/dbr"
import _ "github.com/lib/pq"
func main() {
const q = `SELECT 1 WHERE '{"test":true}'::JSONB ? ?`
conn, err := dbr.Open("postgres", "", nil)
if err != nil {
panic(err)
}
sess := conn.NewSession(nil)
_, err = sess.SelectBySql(q, "test").Load(nil)
if err != nil {
panic(err)
}
}
sergebezborodov commented
is there any solutions?
I have same problem, when my string has ?
it fails at file interpolate.go:
if strings.Count(query, placeholder) != len(value) {
mauri870 commented
I have the same issue as well, but when trying to insert a dynamic JSONB parsed in a struct
taylorchu commented
It seems like we need to have a way to express ?
literal. In go formatter, we use %%
to express %
literal, it seems like ??
should be fine. (This is not yet implemented.)
teubanks commented
This is also an issue for us