-
Notifications
You must be signed in to change notification settings - Fork 221
Open
Description
Describe the bug
When using a null sql.NullInt32 in a query using postgres dialect, the created query uses WHERE x = NULL, instead of the correct WHERE x is NULL.
To Reproduce
package main
import (
"database/sql"
"fmt"
"github.com/doug-martin/goqu/v9"
)
func main() {
sql, _, _ := goqu.Dialect("postgres").From(goqu.T("table")).Select("Id").Where(goqu.Ex{"Val": sql.NullInt32{}}).ToSQL()
fmt.Println(sql)
sql, _, _ = goqu.Dialect("postgres").From(goqu.T("table")).Select("Id").Where(goqu.Ex{"Val": nil}).ToSQL()
fmt.Println(sql)
}
=>
SELECT "Id" FROM "table" WHERE ("Val" = NULL) // Wrong
SELECT "Id" FROM "table" WHERE ("Val" IS NULL) // Right
Expected behavior
When using sql.NullX as a null value, expect to use correctly
Dialect:
- postgres
- mysql
- sqlite3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels