From 658f0fd1309cc024bd261cdc6217b8fdf37d6af9 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 10 May 2022 16:28:24 +0800 Subject: [PATCH] Update SqlSugar.MySqlConnectorCore --- .../MySql/SqlBuilder/MySqlInsertBuilder.cs | 10 +++++++--- .../MySql/SqlBuilder/MySqlQueryBuilder.cs | 4 ++++ .../MySql/SqlBuilder/MySqlUpdateBuilder.cs | 10 +++++++--- .../SqlSugar.MySqlConnectorCore.csproj | 2 +- .../SqlSugar.MySqlConnectorCore.nuspec | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs index 482a21885..aa40e6c1b 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs @@ -27,7 +27,8 @@ namespace SqlSugar.MySqlConnector } } } - public override object FormatValue(object value) + int i = 0; + public object FormatValue(object value,string name) { var n = "N"; if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar) @@ -72,7 +73,10 @@ namespace SqlSugar.MySqlConnector } else if (type == UtilConstants.StringType || type == UtilConstants.ObjType) { - return n+"'" + GetString(value).ToSqlFilter() + "'"; + ++i; + var parameterName = this.Builder.SqlParameterKeyWord + name + i; + this.Parameters.Add(new SugarParameter(parameterName, value)); + return parameterName; } else { @@ -115,7 +119,7 @@ namespace SqlSugar.MySqlConnector foreach (var item in groupList) { batchInsetrSql.Append("("); - insertColumns = string.Join(",", item.Select(it => FormatValue(it.Value))); + insertColumns = string.Join(",", item.Select(it => FormatValue(it.Value,it.PropertyName))); batchInsetrSql.Append(insertColumns); if (groupList.Last() == item) { diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs index c69226ff6..737811f52 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs @@ -62,6 +62,10 @@ namespace SqlSugar.MySqlConnector } this.OrderByValue = oldOrderValue; result = GetSqlQuerySql(result); + if (result.IndexOf("-- No table") > 0) + { + return "-- No table"; + } return result; } private string ToCountSqlString() diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs index 4c7d9132f..6dd742786 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs @@ -59,7 +59,7 @@ namespace SqlSugar.MySqlConnector { updateTable.Append(SqlTemplateBatchUnion); } - updateTable.Append("\r\n SELECT " + string.Join(",", columns.Select(it => string.Format(SqlTemplateBatchSelect, FormatValue(it.Value),this.Builder.GetTranslationColumnName(it.DbColumnName))))); + updateTable.Append("\r\n SELECT " + string.Join(",", columns.Select(it => string.Format(SqlTemplateBatchSelect, FormatValue(it.Value,it.PropertyName),this.Builder.GetTranslationColumnName(it.DbColumnName))))); ++i; } pageIndex++; @@ -89,7 +89,8 @@ namespace SqlSugar.MySqlConnector } return batchUpdateSql.ToString(); } - public override object FormatValue(object value) + int i = 0; + public object FormatValue(object value,string name) { var n = "N"; if (this.Context.CurrentConnectionConfig.MoreSettings != null&&this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar) @@ -142,7 +143,10 @@ namespace SqlSugar.MySqlConnector } else if (type == UtilConstants.StringType || type == UtilConstants.ObjType) { - return n+"'" + GetString(value).ToSqlFilter() + "'"; + ++i; + var parameterName = this.Builder.SqlParameterKeyWord + name + i; + this.Parameters.Add(new SugarParameter(parameterName, value)); + return parameterName; } else { diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.csproj b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.csproj index ddcd26f19..bef77ff7e 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.csproj +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.csproj @@ -2,7 +2,7 @@ netstandard2.1 - 1.1 + 1.3 diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec index 1d96932e3..a65af8b7d 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec @@ -2,7 +2,7 @@ SqlSugar.MySqlConnectorCore - 1.1 + 1.3 sunkaixuan Landa http://www.apache.org/licenses/LICENSE-2.0.html