Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgre JSONB ? operator #106

Closed
ashtonian opened this issue Oct 9, 2017 · 5 comments · Fixed by #141
Closed

Postgre JSONB ? operator #106

ashtonian opened this issue Oct 9, 2017 · 5 comments · Fixed by #141

Comments

@ashtonian
Copy link

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
Copy link

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
Copy link

I have the same issue as well, but when trying to insert a dynamic JSONB parsed in a struct

@taylorchu
Copy link
Contributor

taylorchu commented Jan 29, 2018

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
Copy link

teubanks commented May 9, 2018

This is also an issue for us

@antoniomo
Copy link
Contributor

antoniomo commented Jul 18, 2018

This should be open since bbb1206 inserts the doubled placeholder on the final query, causing a pq driver bug. I patched it on #141 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants