diff --git a/internal/dinosql/gen.go b/internal/dinosql/gen.go index 54d678d47e..d26691750e 100644 --- a/internal/dinosql/gen.go +++ b/internal/dinosql/gen.go @@ -537,7 +537,7 @@ func (r Result) goInnerType(col core.Column) string { case "bytea", "blob", "pg_catalog.bytea": return "[]byte" - case "pg_catalog.timestamp", "pg_catalog.timestamptz": + case "pg_catalog.timestamp", "pg_catalog.timestamptz", "timestamptz": if notNull { return "time.Time" } diff --git a/internal/dinosql/gen_test.go b/internal/dinosql/gen_test.go index 9b366a08a4..16846b84cc 100644 --- a/internal/dinosql/gen_test.go +++ b/internal/dinosql/gen_test.go @@ -75,3 +75,23 @@ func TestColumnsToStruct(t *testing.T) { t.Errorf("struct mismatch: \n%s", diff) } } + +func TestInnerType(t *testing.T) { + r := Result{} + for _, tc := range []struct { + col pg.Column + expected string + }{ + { + pg.Column{Name: "created", DataType: "timestamptz", NotNull: true}, + "time.Time", + }, + } { + tt := tc + t.Run(tt.col.Name+"-"+tt.col.DataType, func(t *testing.T) { + if diff := cmp.Diff(tt.expected, r.goType(tt.col)); diff != "" { + t.Errorf("struct mismatch: \n%s", diff) + } + }) + } +}