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

Select statement has invalid NULL check syntax when using implicit nil value #272

Open
1 of 3 tasks
sieuwerts opened this issue May 10, 2021 · 1 comment
Open
1 of 3 tasks

Comments

@sieuwerts
Copy link

Describe the bug
Select statement has invalid NULL check syntax when using goqu.Ex as where statement with implicit nil value (nil pointer).

To Reproduce
https://play.golang.org/p/X9YaafCJmn-

package main

import (
	"fmt"

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

func main() {
	db := goqu.Dialect("postgres")
	var val *int

	query, _, _ := db.From(goqu.T("table")).Where(goqu.Ex{"explicit_nil": nil, "implicit_nil": val}).ToSQL()

	fmt.Println(query) // SELECT * FROM "table" WHERE (("explicit_nil" IS NULL) AND ("implicit_nil" = NULL))
}

Expected behaviour
When using goqu.Ex in a while condition, I expect to get ...WHERE ("field" IS NULL)... and not ...WHERE ("field" = NULL)..., regardless if I use an implicit, or explicit nil value.

Dialect:

  • postgres
  • mysql
  • sqlite3
@nitaigao
Copy link

I just hit this, is there any update or workaround?

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

3 participants