From ac1edf10d532ec78884ad82830d399c601088f1b Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 10 Aug 2022 23:38:54 +0800 Subject: [PATCH] Update .net core project --- .../MySql/DbMaintenance/MySqlDbMaintenance.cs | 10 +++++----- .../MySql/DbMaintenance/MySqlDbMaintenance.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/DbMaintenance/MySqlDbMaintenance.cs index ba9ef9c8e..8897225ad 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -452,18 +452,18 @@ namespace SqlSugar.MySqlConnector { defaultValue = ""; } - if (defaultValue.ToLower().IsIn("now()", "current_timestamp")|| defaultValue.ToLower().Contains("current_timestamp")) + 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; } - else if (defaultValue=="0"|| defaultValue == "1") + else if (defaultValue == "0" || defaultValue == "1") { - string sql = string.Format(AddDefaultValueSql.Replace("'",""), tableName, columnName, defaultValue); + string sql = string.Format(AddDefaultValueSql.Replace("'", ""), tableName, columnName, defaultValue); this.Context.Ado.ExecuteCommand(sql); return true; } diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index 37fc43e77..7f2d81b5e 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -454,18 +454,18 @@ namespace SqlSugar { defaultValue = ""; } - if (defaultValue.ToLower().IsIn("now()", "current_timestamp")|| defaultValue.ToLower().Contains("current_timestamp")) + 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; } - else if (defaultValue=="0"|| defaultValue == "1") + else if (defaultValue == "0" || defaultValue == "1") { - string sql = string.Format(AddDefaultValueSql.Replace("'",""), tableName, columnName, defaultValue); + string sql = string.Format(AddDefaultValueSql.Replace("'", ""), tableName, columnName, defaultValue); this.Context.Ado.ExecuteCommand(sql); return true; }