Skip to content

Commit

Permalink
fix bug in mysql: default value CURRENT_TIMESTAMP go-xorm#1391
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Aug 14, 2019
1 parent ce79b1c commit 77b41f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dialect_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
col.IsAutoIncrement = true
}

if col.SQLType.IsText() || col.SQLType.IsTime() {
if col.SQLType.IsTime() && col.Default == "CURRENT_TIMESTAMP" {
if strings.Contains(extra, "CURRENT_TIMESTAMP") {
col.Default = "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
}
} else if col.SQLType.IsText() || col.SQLType.IsTime() {
if col.Default != "" {
col.Default = "'" + col.Default + "'"
} else {
Expand Down

0 comments on commit 77b41f9

Please sign in to comment.