goqu
goqu copied to clipboard
Select statement has invalid NULL check syntax when using implicit nil value
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:
- [x] postgres
- [ ] mysql
- [ ] sqlite3
I just hit this, is there any update or workaround?