diff --git a/Src/Asp.Net/MySqlTest/UnitTest/UnitCustom01.cs b/Src/Asp.Net/MySqlTest/UnitTest/UnitCustom01.cs index eeefa398d..065c3e215 100644 --- a/Src/Asp.Net/MySqlTest/UnitTest/UnitCustom01.cs +++ b/Src/Asp.Net/MySqlTest/UnitTest/UnitCustom01.cs @@ -22,6 +22,10 @@ namespace OrmTest IsAutoCloseConnection = true }); + ssc.Aop.OnLogExecuting = (s, p) => + { + Console.WriteLine(s); + }; ssc.CodeFirst.InitTables(); var expMethods = new List(); @@ -75,9 +79,22 @@ namespace OrmTest } + ssc.CodeFirst.InitTables(); + + ssc.CodeFirst.InitTables(); } } + public class unittest1231sdaa + { + [SugarColumn(IndexGroupNameList = new string[] { "index3" }, ColumnDataType = "DATETIME(6)", DefaultValue = "CURRENT_TIMESTAMP(6)")] + public DateTime update_time { get; set; } + } + public class unittest1231sdaa2 + { + [SugarColumn(IndexGroupNameList = new string[] { "index3" }, ColumnDataType = "DATETIME", DefaultValue = "CURRENT_TIMESTAMP")] + public DateTime update_time { get; set; } + } [SugarTable("unitstudent1111")] public class Student { diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index 5ee078454..c6150749c 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -438,7 +438,8 @@ namespace SqlSugar { string template = "ALTER table {0} CHANGE COLUMN {1} {1} {3} default {2}"; var dbColumnInfo = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName).First(it => it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase)); - string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType); + var value = Regex.Match(defaultValue, @"\(\d\)$").Value; + string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType+ value); this.Context.Ado.ExecuteCommand(sql); return true; }