Fix bool value mapping.

pull/48/head
Lau 6 years ago
parent db47437539
commit 48bc49d3a4

@ -37,9 +37,9 @@ namespace EntityFrameworkCore.Jet.Query.Internal
{ {
new CaseWhenClause( new CaseWhenClause(
sqlExpression, sqlExpression,
_sqlExpressionFactory.ApplyDefaultTypeMapping(_sqlExpressionFactory.Constant(/*true*/ 1))) _sqlExpressionFactory.ApplyDefaultTypeMapping(_sqlExpressionFactory.Constant(true)))
}, },
_sqlExpressionFactory.Constant(/*false*/ 0)) _sqlExpressionFactory.Constant(false))
: sqlExpression; : sqlExpression;
} }
@ -268,10 +268,10 @@ namespace EntityFrameworkCore.Jet.Query.Internal
_isSearchCondition = parentSearchCondition; _isSearchCondition = parentSearchCondition;
var newFunction = sqlFunctionExpression.Update(instance, arguments); var newFunction = sqlFunctionExpression.Update(instance, arguments);
var condition = string.Equals(sqlFunctionExpression.Name, "FREETEXT") // var condition = string.Equals(sqlFunctionExpression.Name, "FREETEXT")
|| string.Equals(sqlFunctionExpression.Name, "CONTAINS"); // || string.Equals(sqlFunctionExpression.Name, "CONTAINS");
return ApplyConversion(newFunction, condition); return ApplyConversion(newFunction, /* condition */ false);
} }
protected override Expression VisitSqlParameter(SqlParameterExpression sqlParameterExpression) protected override Expression VisitSqlParameter(SqlParameterExpression sqlParameterExpression)

@ -224,18 +224,16 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal
protected override Expression VisitOrdering(OrderingExpression orderingExpression) protected override Expression VisitOrdering(OrderingExpression orderingExpression)
{ {
// Instead of the following, we are using SearchConditionConvertingExpressionVisitor.
// Jet uses the value -1 as True, so ordering by a boolean expression will first list the True values // Jet uses the value -1 as True, so ordering by a boolean expression will first list the True values
// before the False values, which is the opposite of what .NET and other DBMS do, which are using 1 as True. // before the False values, which is the opposite of what .NET and other DBMS do, which are using 1 as True.
/*
if (orderingExpression.Expression.TypeMapping == _boolTypeMapping) if (orderingExpression.Expression.TypeMapping == _boolTypeMapping)
{ {
orderingExpression = new OrderingExpression( orderingExpression = new OrderingExpression(
orderingExpression.Expression, orderingExpression.Expression,
!orderingExpression.IsAscending); !orderingExpression.IsAscending);
} }
*/
return base.VisitOrdering(orderingExpression); return base.VisitOrdering(orderingExpression);
} }

@ -23,7 +23,7 @@ namespace EntityFrameworkCore.Jet.Storage.Internal
protected override string GenerateNonNullSqlLiteral(object value) protected override string GenerateNonNullSqlLiteral(object value)
=> (bool) value => (bool) value
? "True" ? "TRUE"
: "False"; : "FALSE";
} }
} }
Loading…
Cancel
Save