Skip to content

Commit 77b41f9

Browse files
committed
fix bug in mysql: default value CURRENT_TIMESTAMP go-xorm#1391
1 parent ce79b1c commit 77b41f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dialect_mysql.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,11 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
411411
col.IsAutoIncrement = true
412412
}
413413

414-
if col.SQLType.IsText() || col.SQLType.IsTime() {
414+
if col.SQLType.IsTime() && col.Default == "CURRENT_TIMESTAMP" {
415+
if strings.Contains(extra, "CURRENT_TIMESTAMP") {
416+
col.Default = "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
417+
}
418+
} else if col.SQLType.IsText() || col.SQLType.IsTime() {
415419
if col.Default != "" {
416420
col.Default = "'" + col.Default + "'"
417421
} else {

0 commit comments

Comments
 (0)