mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
- 修复 Expression OrElse 两侧括号丢失的 bug;
- 修复 Expression DateTime 类型 CompareTo 在 MySql/SqlServer 下的 bug;
This commit is contained in:
@ -771,10 +771,11 @@ namespace FreeSql.Internal {
|
||||
if (string.IsNullOrEmpty(other99Exp) == false) return other99Exp;
|
||||
return "";
|
||||
}
|
||||
if (expBinary.NodeType == ExpressionType.Coalesce) {
|
||||
return _common.IsNull(
|
||||
ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style),
|
||||
ExpressionLambdaToSql(expBinary.Right, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style));
|
||||
switch (expBinary.NodeType) {
|
||||
case ExpressionType.Coalesce:
|
||||
return _common.IsNull(ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style), ExpressionLambdaToSql(expBinary.Right, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style));
|
||||
case ExpressionType.OrElse:
|
||||
return $"({ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style)} OR {ExpressionLambdaToSql(expBinary.Right, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style)})";
|
||||
}
|
||||
if (dicExpressionOperator.TryGetValue(expBinary.NodeType, out var tryoper) == false) return "";
|
||||
var left = ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style);
|
||||
|
@ -335,7 +335,7 @@ namespace FreeSql.MySql {
|
||||
}
|
||||
break;
|
||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||
case "CompareTo": return $"(({left}) - ({getExp(exp.Arguments[0])}))";
|
||||
case "CompareTo": return $"timestampdiff(microsecond,{getExp(exp.Arguments[0])},{left})";
|
||||
case "ToString": return $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')";
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ namespace FreeSql.SqlServer {
|
||||
}
|
||||
break;
|
||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||
case "CompareTo": return $"(({left}) - ({getExp(exp.Arguments[0])}))";
|
||||
case "CompareTo": return $"datediff(second,{getExp(exp.Arguments[0])},{left})";
|
||||
case "ToString": return $"convert(varchar, {left}, 121)";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user