QuestDb Last On

This commit is contained in:
sunkaixuan
2023-06-23 14:35:05 +08:00
parent 9b7d48633c
commit c3931239df
3 changed files with 15 additions and 1 deletions

View File

@@ -15,7 +15,11 @@ namespace SqlSugar
public override ISugarQueryable<T> PartitionBy(string groupFileds) public override ISugarQueryable<T> PartitionBy(string groupFileds)
{ {
this.GroupBy(groupFileds); if (this.QueryBuilder.Take == 1)
{
this.QueryBuilder.Take = null;
}
this.QueryBuilder.PartitionByValue=groupFileds;
return this; return this;
} }
} }

View File

@@ -78,6 +78,11 @@ namespace SqlSugar
{ {
result = result + TranLock; result = result + TranLock;
} }
if (this.PartitionByValue.HasValue())
{
var addSql = " LATEST ON " + UtilMethods.ReplaceFirstMatch(this.PartitionByValue, ",", " PARTITION BY ");
result =result+ addSql;
}
return result; return result;
} }
private string ToCountSqlString() private string ToCountSqlString()

View File

@@ -496,6 +496,11 @@ namespace SqlSugar
{ {
return type.IsValueType ? Activator.CreateInstance(type) : null; return type.IsValueType ? Activator.CreateInstance(type) : null;
} }
public static string ReplaceFirstMatch(string input, string pattern, string replacement)
{
Regex regex = new Regex(pattern);
return regex.Replace(input, replacement, 1);
}
public static string ReplaceSqlParameter(string itemSql, SugarParameter itemParameter, string newName) public static string ReplaceSqlParameter(string itemSql, SugarParameter itemParameter, string newName)
{ {
itemSql = Regex.Replace(itemSql, string.Format(@"{0} ", "\\" + itemParameter.ParameterName), newName + " ", RegexOptions.IgnoreCase); itemSql = Regex.Replace(itemSql, string.Format(@"{0} ", "\\" + itemParameter.ParameterName), newName + " ", RegexOptions.IgnoreCase);