Browse Source

Update PgSql exp !bool bug

pull/4/MERGE
sunkaixuna 3 years ago
parent
commit
3a5a9a5e95
  1. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs
  2. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/UnaryExpressionResolve.cs
  3. 13
      Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLExpressionContext.cs

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

@ -87,7 +87,7 @@ namespace SqlSugar
var result = this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
{
Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs(){ IsMember=true, MemberName=parameter.CommonTempData.ObjToString()+"=1" },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=parameter.CommonTempData.ObjToString()+"=1",Type=UtilConstants.BoolType },
new MethodCallExpressionArgs(){ IsMember=true,MemberName=AppendParameter(0) },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=AppendParameter(1) }
}

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/UnaryExpressionResolve.cs

@ -150,7 +150,7 @@ namespace SqlSugar
var result= this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
{
Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs(){ IsMember=true, MemberName=parameter.CommonTempData.ObjToString()+"=1" },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=parameter.CommonTempData.ObjToString()+"=1",Type=UtilConstants.BoolType },
new MethodCallExpressionArgs(){ IsMember=true,MemberName=AppendParameter(0) },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=AppendParameter(1) }
}

13
Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLExpressionContext.cs

@ -96,6 +96,19 @@ namespace SqlSugar
}
public class PostgreSQLMethod : DefaultDbMethod, IDbMethods
{
public override string IIF(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
var parameter3 = model.Args[2];
if (parameter.Type == UtilConstants.BoolType)
{
parameter.MemberName = parameter.MemberName.ToString().Replace("=1", "=true");
parameter2.MemberName = false;
parameter3.MemberName = true;
}
return string.Format("( CASE WHEN {0} THEN {1} ELSE {2} END )", parameter.MemberName, parameter2.MemberName, parameter3.MemberName);
}
public override string DateValue(MethodCallExpressionModel model)
{
var parameter = model.Args[0];

Loading…
Cancel
Save