diff --git a/tables.go b/tables.go index c8968d0e..65499f63 100644 --- a/tables.go +++ b/tables.go @@ -129,7 +129,7 @@ func (t *Table) Column(name string, colType string, options Options) error { } else { t.Columns = append(t.Columns, c) } - if (name == "created_at" || name == "updated_at") && colType != "time" { + if (name == "created_at" || name == "updated_at") && colType != "timestamp" { // timestamp macro only works for time type t.useTimestampMacro = false } diff --git a/tables_test.go b/tables_test.go index add40dcb..f8a01d48 100644 --- a/tables_test.go +++ b/tables_test.go @@ -111,6 +111,22 @@ func Test_Table_StringerAutoDisableTimestamps(t *testing.T) { r.NoError(table.Column("created_at", "int", nil)) r.Equal(expected, table.String()) + + // timestamp columns provided but same as default + expected = + `create_table("users") { + t.Column("name", "string") + t.Timestamps() +}` + + table = fizz.NewTable("users", map[string]interface{}{ + "timestamps": true, + }) + r.NoError(table.Column("name", "string", nil)) + r.NoError(table.Column("created_at", "timestamp", nil)) + r.NoError(table.Column("updated_at", "timestamp", nil)) + + r.Equal(expected, table.String()) } func Test_Table_StringerIndex(t *testing.T) { diff --git a/version.go b/version.go index 4555c951..ff855b8f 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package fizz // Version gives the current fizz version. -const Version = "v1.9.4" +const Version = "v1.9.5"