Skip to content

Commit

Permalink
fix: remove zero value default tag
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Apr 20, 2022
1 parent 2c8e792 commit 4f77776
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/model/tbl_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,16 @@ func (c *Column) buildGormTag() string {

// withDefaultValue check if col has default value and not created_at or updated_at
func (c *Column) withDefaultValue() (normal bool) {
return c.defaultValue() != "" && c.Name() != "created_at" && c.Name() != "updated_at"
return c.defaultValue() != "" && c.defaultValue() != "0" &&
c.Name() != "created_at" && c.Name() != "updated_at"
}

func (c *Column) defaultValue() string {
df, ok := c.DefaultValue()
if !ok {
return ""
}
if strings.TrimSpace(df) == "" {
return "'" + df + "'"
}
return df
return "'" + df + "'"
}

func (c *Column) columnType() (v string) {
Expand Down

0 comments on commit 4f77776

Please sign in to comment.