jmoiron / modl

golang database modelling library
MIT License
479 stars 48 forks source link

sql.NullTime doesn't work for postgres #54

Open tamim opened 3 years ago

tamim commented 3 years ago

sql.NullTime is not working as expected in the postgres db.

Here is an example -

type SampleEvent struct {
    ID        string   `db:"id"`
    CreatedAt sql.NullTime `db:"created_at"`
}

modl is creating this table such as the created_at column is varchar instead of timestamp.

The fix is in dialect.go file, line 255

case "Time", "Nulltime":
    return "timestamp with time zone"

here Nulltime should be NullTime.