From 60d329265aec552d44aaf59bbb0c01bf4ae76ba8 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Sat, 2 Dec 2023 00:05:11 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=20Update=20=E6=97=A0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=97=B6=E4=B8=8D=E5=81=9A=E4=BB=BB=E4=BD=95?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/Internal/CommonProvider/DeleteProvider.cs | 4 ++-- FreeSql/Internal/CommonProvider/UpdateProvider.cs | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/FreeSql/Internal/CommonProvider/DeleteProvider.cs b/FreeSql/Internal/CommonProvider/DeleteProvider.cs index a0b8c0908..30588fadf 100644 --- a/FreeSql/Internal/CommonProvider/DeleteProvider.cs +++ b/FreeSql/Internal/CommonProvider/DeleteProvider.cs @@ -205,7 +205,7 @@ public void ToSqlFetch(Action fetch) _tableRule = old => name; sb.Clear().Append("DELETE FROM ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append(newwhere); _interceptSql?.Invoke(sb); - fetch(sb); + if (sb.Length > 0) fetch(sb); } _tableRule = oldTableRule; return; @@ -240,7 +240,7 @@ async public Task ToSqlFetchAsync(Func fetchAsync) _tableRule = old => name; sb.Clear().Append("DELETE FROM ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append(newwhere); _interceptSql?.Invoke(sb); - await fetchAsync(sb); + if (sb.Length > 0) await fetchAsync(sb); } _tableRule = oldTableRule; return; diff --git a/FreeSql/Internal/CommonProvider/UpdateProvider.cs b/FreeSql/Internal/CommonProvider/UpdateProvider.cs index 503884464..26d1bbe97 100644 --- a/FreeSql/Internal/CommonProvider/UpdateProvider.cs +++ b/FreeSql/Internal/CommonProvider/UpdateProvider.cs @@ -1002,7 +1002,7 @@ public void ToSqlFetch(Action fetch) { var sb1 = new StringBuilder(); ToSqlExtension110(sb1, false); - fetch(sb1); + if (sb1.Length > 0) fetch(sb1); return; } if (_where.Length == 0) return; @@ -1035,7 +1035,7 @@ async public Task ToSqlFetchAsync(Func fetchAsync) { var sb1 = new StringBuilder(); ToSqlExtension110(sb1, false); - await fetchAsync(sb1); + if (sb1.Length > 0) await fetchAsync(sb1); sb1.Clear(); return; } @@ -1126,7 +1126,11 @@ public virtual void ToSqlExtension110(StringBuilder sb, bool isAsTableSplited) ++colidx; } } - if (colidx == 0) return; + if (colidx == 0) + { + sb.Clear(); + return; + } } else if (_source.Count > 1)