Skip to content

Commit

Permalink
fix: remove default tag CURRENT_TIMESPAMP
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Jun 2, 2022
1 parent 1f6224f commit 8631878
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/model/tbl_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func (c *Column) buildGormTag() string {

// needDefaultTag check if default tag needed
func (c *Column) needDefaultTag(defaultTagValue string) bool {
if defaultTagValue == "" {
return false
}
switch c.ScanType().Kind() {
case reflect.Bool:
return defaultTagValue != "false"
Expand All @@ -124,7 +127,7 @@ func (c *Column) needDefaultTag(defaultTagValue string) bool {
case reflect.String:
return defaultTagValue != ""
case reflect.Struct:
return strings.Trim(defaultTagValue, "'0:- ") != ""
return strings.Trim(defaultTagValue, "'0:- ") != "" && strings.TrimSpace(defaultTagValue) != "CURRENT_TIMESPAMP"
}
return c.Name() != "created_at" && c.Name() != "updated_at"
}
Expand Down

0 comments on commit 8631878

Please sign in to comment.