mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add check fieldname format
This commit is contained in:
parent
94c874fdd8
commit
d6e9d2cebb
@ -735,6 +735,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
|
||||
{
|
||||
orderFileds = orderFileds.ToCheckField();
|
||||
var orderByValue = QueryBuilder.OrderByValue;
|
||||
if (QueryBuilder.OrderByValue.IsNullOrEmpty())
|
||||
{
|
||||
@ -771,6 +772,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual ISugarQueryable<T> GroupBy(string groupFileds)
|
||||
{
|
||||
groupFileds = groupFileds.ToCheckField();
|
||||
var croupByValue = QueryBuilder.GroupByValue;
|
||||
if (QueryBuilder.GroupByValue.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ namespace SqlSugar
|
||||
}
|
||||
string oldName = item.FieldName;
|
||||
item.FieldName = GetTranslationColumnName(item.FieldName);
|
||||
Check.Exception(item.FieldName.Contains("--"), "Field name is error format");
|
||||
item.FieldName = item.FieldName.ToCheckField();
|
||||
switch (item.ConditionalType)
|
||||
{
|
||||
case ConditionalType.Equal:
|
||||
|
@ -47,6 +47,26 @@ namespace SqlSugar
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check field format
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToCheckField(this string value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
if (value.IsContainsIn(";", "--"))
|
||||
{
|
||||
throw new Exception($"{value} format error ");
|
||||
}
|
||||
else if (value.IsContainsIn("'")&&(value.Length- value.Replace("'","").Length)%2!=0)
|
||||
{
|
||||
throw new Exception($"{value} format error ");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
internal static string ToLower(this string value ,bool isAutoToLower)
|
||||
{
|
||||
if (value == null) return null;
|
||||
|
Loading…
Reference in New Issue
Block a user