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

sql syntax error: "SELECT ... WHERE foobar IS $1" #165

Closed
1 task done
yeaha opened this issue Sep 19, 2019 · 3 comments
Closed
1 task done

sql syntax error: "SELECT ... WHERE foobar IS $1" #165

yeaha opened this issue Sep 19, 2019 · 3 comments

Comments

@yeaha
Copy link
Contributor

yeaha commented Sep 19, 2019

Describe the bug
After upgrade to v9, some of my select statment got syntax error

To Reproduce

package main

import (
	"database/sql"
	"fmt"

	"github.com/doug-martin/goqu/v9"
	_ "github.com/doug-martin/goqu/v9/dialect/postgres"
	_ "github.com/lib/pq"
)

func main() {
	query, args, _ := goqu.Dialect("postgres").
		From("mytable").
		Prepared(true).
		Where(goqu.C("foobar").IsNull()).
		ToSQL()

	// OUTPUT: SELECT * FROM "mytable" WHERE ("foobar" IS $1)
	fmt.Println(query)

	db, _ := sql.Open("postgres", "database=test host=127.0.0.1 port=5432 sslmode=disable")

	if _, err := db.Query(query, args...); err != nil {
		// OUTPUT: panic: pq: syntax error at or near "$1"
		panic(err)
	}
}

Dialect:

  • postgres
@yeaha yeaha changed the title sql syntax: "SELECT ... WHERE foobar IS ?" sql syntax error: "SELECT ... WHERE foobar IS ?" Sep 19, 2019
@yeaha yeaha changed the title sql syntax error: "SELECT ... WHERE foobar IS ?" sql syntax error: "SELECT ... WHERE foobar IS $1" Sep 19, 2019
@doug-martin
Copy link
Owner

@yeaha investigating now.

doug-martin added a commit that referenced this issue Sep 19, 2019
* [FIXED] Issue where `NULL`, `TRUE` and `FALSE` are interpolated when using an `IS` clause. #165
@doug-martin doug-martin mentioned this issue Sep 19, 2019
doug-martin added a commit that referenced this issue Sep 19, 2019
* [FIXED] Issue where `NULL`, `TRUE` and `FALSE` are interpolated when using an `IS` clause. #165
@doug-martin
Copy link
Owner

v9.0.1 is published and should fix this. Let me know if you have any other issues.

Thank you for the bug report!

@yeaha
Copy link
Contributor Author

yeaha commented Sep 20, 2019

It's work.
Thank you.

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

No branches or pull requests

2 participants