Browse Source

Update .net core project

SqlSugar5
sunkaixuan 2 years ago
parent
commit
ac1edf10d5
  1. 4
      Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/DbMaintenance/MySqlDbMaintenance.cs
  2. 4
      Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

4
Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/DbMaintenance/MySqlDbMaintenance.cs

@ -454,10 +454,10 @@ namespace SqlSugar.MySqlConnector
}
if (defaultValue.ToLower().IsIn("now()", "current_timestamp") || defaultValue.ToLower().Contains("current_timestamp"))
{
string template = "ALTER table {0} CHANGE COLUMN {1} {1} {3} default {2}";
string template = "ALTER table {0} CHANGE COLUMN {1} {1} {3} {4} default {2} COMMENT '{5}'";
var dbColumnInfo = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName).First(it => it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase));
var value = Regex.Match(defaultValue, @"\(\d\)$").Value;
string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType+ value);
string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType + value, dbColumnInfo.IsNullable ? " NULL " : " NOT NULL ", dbColumnInfo.ColumnDescription);
this.Context.Ado.ExecuteCommand(sql);
return true;
}

4
Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

@ -456,10 +456,10 @@ namespace SqlSugar
}
if (defaultValue.ToLower().IsIn("now()", "current_timestamp") || defaultValue.ToLower().Contains("current_timestamp"))
{
string template = "ALTER table {0} CHANGE COLUMN {1} {1} {3} default {2}";
string template = "ALTER table {0} CHANGE COLUMN {1} {1} {3} {4} default {2} COMMENT '{5}'";
var dbColumnInfo = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName).First(it => it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase));
var value = Regex.Match(defaultValue, @"\(\d\)$").Value;
string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType+ value);
string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType + value, dbColumnInfo.IsNullable ? " NULL " : " NOT NULL ", dbColumnInfo.ColumnDescription);
this.Context.Ado.ExecuteCommand(sql);
return true;
}

Loading…
Cancel
Save