- 修复 因兼容 #184 导致 MySql Enum 表达式解析为 int 的 bug;

- 修复 FreeSql.Provider.MySqlConnector Enum 自定义元素值,导致值计算错误的 bug;
This commit is contained in:
28810
2020-03-31 21:43:07 +08:00
parent c6c874f612
commit d4fd81679d
6 changed files with 358 additions and 8 deletions

View File

@ -489,7 +489,9 @@ namespace FreeSql.Internal
var right = ExpressionLambdaToSql(rightExp, tsc);
if (right != "NULL" && isLeftMapType &&
//判断参数化后的bug
!(right.Contains('@') || right.Contains('?') || right.Contains(':')))
!(right.Contains('@') || right.Contains('?') || right.Contains(':')) &&
//三元表达式后,取消此条件 #184
tsc.mapType != null)
{
var enumType = leftMapColumn.CsType.NullableTypeOrThis();
if (enumType.IsEnum)
@ -505,7 +507,9 @@ namespace FreeSql.Internal
left = ExpressionLambdaToSql(leftExp, tsc);
if (left != "NULL" && isRightMapType &&
//判断参数化后的bug
!(left.Contains('@') || left.Contains('?') || left.Contains(':')))
!(left.Contains('@') || left.Contains('?') || left.Contains(':')) &&
//三元表达式后,取消此条件 #184
tsc.mapType != null)
{
var enumType = rightMapColumn.CsType.NullableTypeOrThis();
if (enumType.IsEnum)
@ -598,7 +602,12 @@ namespace FreeSql.Internal
case ExpressionType.Constant: return formatSql((exp as ConstantExpression)?.Value, tsc.mapType, tsc.mapColumnTmp, null);
case ExpressionType.Conditional:
var condExp = exp as ConditionalExpression;
return _common.IIF(ExpressionLambdaToSql(condExp.Test, tsc), ExpressionLambdaToSql(condExp.IfTrue, tsc), ExpressionLambdaToSql(condExp.IfFalse, tsc));
var conditionalTestOldMapType = tsc.SetMapTypeReturnOld(null);
var conditionalTestSql = ExpressionLambdaToSql(condExp.Test, tsc);
tsc.SetMapTypeReturnOld(conditionalTestOldMapType);
var conditionalSql = _common.IIF(conditionalTestSql, ExpressionLambdaToSql(condExp.IfTrue, tsc), ExpressionLambdaToSql(condExp.IfFalse, tsc));
tsc.SetMapTypeReturnOld(null);
return conditionalSql;
case ExpressionType.Call:
tsc.mapType = null;
var exp3 = exp as MethodCallExpression;

View File

@ -406,8 +406,7 @@ namespace FreeSql.Internal.CommonProvider
{
case ExpressionType.Equal:
var equalBinaryExp = body as BinaryExpression;
_set.Append(", ").Append(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, equalBinaryExp.Left, null, null))
.Append(" = ").Append(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, equalBinaryExp.Right, null, null));
_set.Append(", ").Append(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, body, null, null));
return this;
case ExpressionType.MemberInit:
var initExp = body as MemberInitExpression;