Convert a null constant in a projection to a variant. We only do this if the type is meant to be a numeric. This is because NULL on its own has some issues when unioning with int values. Some joins with this issue were fixed in an earlier commit

pull/144/head
Christopher Jolly 2 years ago
parent 4fc2cb55b7
commit 08718b8165

@ -350,7 +350,10 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal
{
_nullNumerics.Add(projectionExpression.Alias);
}
return base.VisitProjection(projectionExpression);
parent.Push(projectionExpression);
var result = base.VisitProjection(projectionExpression);
parent.Pop();
return result;
}
protected override Expression VisitColumn(ColumnExpression columnExpression)
@ -498,6 +501,15 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal
{
sqlConstantExpression = (SqlConstantExpression)sqlConstantExpression.ApplyTypeMapping(new JetDateTimeTypeMapping("datetime", _options));
}
parent.TryPeek(out var exp);
if (sqlConstantExpression.Value is null && exp is ProjectionExpression && (sqlConstantExpression.Type == typeof(int) || sqlConstantExpression.Type == typeof(double) || sqlConstantExpression.Type == typeof(float) || sqlConstantExpression.Type == typeof(decimal) || sqlConstantExpression.Type == typeof(short)))
{
Sql.Append("CVar(");
Sql.Append(sqlConstantExpression.TypeMapping!.GenerateSqlLiteral(sqlConstantExpression.Value));
Sql.Append(")");
return sqlConstantExpression;
}
return base.VisitSqlConstant(sqlConstantExpression);
}
@ -760,8 +772,10 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal
}
}
}
return base.VisitSqlFunction(sqlFunctionExpression);
parent.Push(sqlFunctionExpression);
var result = base.VisitSqlFunction(sqlFunctionExpression);
parent.Pop();
return result;
}
protected override Expression VisitCase(CaseExpression caseExpression)

Loading…
Cancel
Save