Update subquery

This commit is contained in:
sunkaixuan 2025-03-11 20:38:19 +08:00
parent 3afb8ce813
commit 5472b5d8bc

View File

@ -186,9 +186,9 @@ namespace SqlSugar
{
var asName = this.context.GetTranslationTableName(asItems.First().Replace(subKey, ""), false);
var repKey = $"\\{this.context.SqlTranslationLeft}.+\\{this.context.SqlTranslationRight}";
if (this.context.CurrentShortName.HasValue())
if (this.context.IsSingle&&this.context.JoinIndex==0&&this.context.CurrentShortName.HasValue()&& isAsAttr&& !asName.Contains(this.context.CurrentShortName))
{
asName = asName + " " + this.context.CurrentShortName;
asName = asName + " " + this.context.CurrentShortName+" ";
}
sqlItems[i] = Regex.Replace(sqlItems[i], repKey, asName);
}
@ -200,7 +200,13 @@ namespace SqlSugar
{
if (sqlItems[i].StartsWith("FROM " + this.context.SqlTranslationLeft))
{
sqlItems[i] = sqlItems[i]+" "+this.context.CurrentShortName +" ";
if (isAsAttr&&sqlItems[i].EndsWith(this.context.CurrentShortName + " "))
{
}
else
{
sqlItems[i] = sqlItems[i] + " " + this.context.CurrentShortName + " ";
}
}
}
}