From 62ca4180adba53f93018be28d753f5261b794bc1 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Fri, 28 Jun 2019 13:13:41 -0700 Subject: [PATCH] Expand fix to reset nullability for all the Visit* methods --- .../Query/Pipeline/NullSemanticsRewritingVisitor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/EFCore.Relational/Query/Pipeline/NullSemanticsRewritingVisitor.cs b/src/EFCore.Relational/Query/Pipeline/NullSemanticsRewritingVisitor.cs index 614bd1dfe72..408a0e3ebf1 100644 --- a/src/EFCore.Relational/Query/Pipeline/NullSemanticsRewritingVisitor.cs +++ b/src/EFCore.Relational/Query/Pipeline/NullSemanticsRewritingVisitor.cs @@ -89,9 +89,10 @@ private SqlParameterExpression VisitSqlParameterExpression(SqlParameterExpressio private SqlUnaryExpression VisitSqlUnaryExpression(SqlUnaryExpression sqlUnaryExpression) { + _isNullable = false; var newOperand = (SqlExpression)Visit(sqlUnaryExpression.Operand); - // IsNull/IsNotNull + // IsNull/IsNotNull if (sqlUnaryExpression.OperatorType == ExpressionType.Equal || sqlUnaryExpression.OperatorType == ExpressionType.NotEqual) { @@ -103,6 +104,7 @@ private SqlUnaryExpression VisitSqlUnaryExpression(SqlUnaryExpression sqlUnaryEx private LikeExpression VisitLikeExpression(LikeExpression likeExpression) { + _isNullable = false; var newMatch = (SqlExpression)Visit(likeExpression.Match); var isNullable = _isNullable; var newPattern = (SqlExpression)Visit(likeExpression.Pattern); @@ -149,6 +151,7 @@ private SqlExpression VisitJoinPredicate(SqlBinaryExpression predicate) private CaseExpression VisitCaseExpression(CaseExpression caseExpression) { + _isNullable = false; // if there is no 'else' there is a possibility of null, when none of the conditions are met // otherwise the result is nullable if any of the WhenClause results OR ElseResult is nullable var isNullable = caseExpression.ElseResult == null; @@ -188,9 +191,11 @@ private SqlFunctionExpression VisitSqlFunctionExpression(SqlFunctionExpression s private SqlBinaryExpression VisitSqlBinaryExpression(SqlBinaryExpression sqlBinaryExpression) { + _isNullable = false; var newLeft = (SqlExpression)Visit(sqlBinaryExpression.Left); var leftNullable = _isNullable; + _isNullable = false; var newRight = (SqlExpression)Visit(sqlBinaryExpression.Right); var rightNullable = _isNullable;