code optimization

This commit is contained in:
sunkaixuna 2021-08-05 21:39:34 +08:00
parent f7b87a78d9
commit 4e05603cea

View File

@ -481,7 +481,12 @@ namespace SqlSugar
if (this.IsSqlQuery && (Skip == null && Take == null))
{
var old = result;
result = System.Text.RegularExpressions.Regex.Match(result, @"^SELECT .* FROM \(((.|\n|\r)*)\) t $").Groups[1].Value;
var regex = @"^SELECT .* FROM \(((.|\n|\r)*)\) t $";
if (this.Context.CurrentConnectionConfig.DbType == DbType.MySql)
{
result = result.Substring(0,result.Length-1);
}
result = System.Text.RegularExpressions.Regex.Match(result,regex).Groups[1].Value;
if (string.IsNullOrEmpty(result))
{
result = old;