From 988e463fbe49c77517d8de6788d7b01b60701214 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 21 Mar 2022 15:22:46 +0800 Subject: [PATCH] Update core --- .../SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs | 5 ++++- .../Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs index 1ef73ef9a..105bf0434 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs @@ -427,7 +427,10 @@ namespace SqlSugar public virtual string ToCountSql(string sql) { - + if (sql != null && sql.Contains("-- No table")) + { + return "-- No table"; + } return string.Format(" SELECT COUNT(1) FROM ({0}) CountTable ", sql); } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs index 3728e960c..30a2f0abd 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs @@ -71,7 +71,14 @@ namespace SqlSugar string result = null; sql = new StringBuilder(); sql.AppendFormat(SqlTemplate, "Count(*)", GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString); - if (IsCount) { return sql.ToString(); } + if (IsCount) + { + if (sql.ToString().Contains("-- No table")) + { + return "-- No table"; + } + return sql.ToString(); + } if (Skip != null && Take == null) { if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];