Skip to content

Commit

Permalink
Remove QueryFailed (#23382)
Browse files Browse the repository at this point in the history
Mainly error in projection binding expression visitor, when we have an unknown extension expression which is hit when client evaluating, (non-client eval we wouldn't reach this code).
Translation failure seems most appropriate error.
Returning NoTranslationExpression will actually provide lesser value in what failed exactly.

Cosmos has a lot of places where it used but those are supposed to invariants and shouldn't exist after Cosmos Query pipeline is updated.

Resolves #22508
  • Loading branch information
smitpatel committed Nov 18, 2020
1 parent 7473e65 commit 4dc48f3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
return newIncludeExpression;

default:
throw new InvalidOperationException(CoreStrings.QueryFailed(extensionExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(extensionExpression.Print()));
}
}

Expand Down Expand Up @@ -336,7 +336,7 @@ protected override Expression VisitMember(MemberExpression memberExpression)
break;

default:
throw new InvalidOperationException(CoreStrings.QueryFailed(memberExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(memberExpression.Print()));
}

var navigationProjection = innerEntityProjection.BindMember(
Expand Down Expand Up @@ -372,7 +372,7 @@ protected override Expression VisitMember(MemberExpression memberExpression)
}

default:
throw new InvalidOperationException(CoreStrings.QueryFailed(memberExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(memberExpression.Print()));
}

Expression NullSafeUpdate(Expression expression)
Expand Down Expand Up @@ -529,7 +529,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
break;

default:
throw new InvalidOperationException(CoreStrings.QueryFailed(methodCallExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(methodCallExpression.Print()));
}

Expression navigationProjection;
Expand Down Expand Up @@ -576,7 +576,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
}

default:
throw new InvalidOperationException(CoreStrings.QueryFailed(methodCallExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(methodCallExpression.Print()));
}
}

Expand Down Expand Up @@ -725,7 +725,7 @@ private void VerifySelectExpression(ProjectionBindingExpression projectionBindin
{
if (projectionBindingExpression.QueryExpression != _selectExpression)
{
throw new InvalidOperationException(CoreStrings.QueryFailed(projectionBindingExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(projectionBindingExpression.Print()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private int GetProjectionIndex(ProjectionBindingExpression projectionBindingExpr
=> projectionBindingExpression.ProjectionMember != null
? _selectExpression.GetMappedProjection(projectionBindingExpression.ProjectionMember).GetConstantValue<int>()
: projectionBindingExpression.Index
?? throw new InvalidOperationException(CoreStrings.QueryFailed(projectionBindingExpression.Print(), GetType().Name));
?? throw new InvalidOperationException(CoreStrings.TranslationFailed(projectionBindingExpression.Print()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression)
break;
default:
throw new InvalidOperationException(
CoreStrings.QueryFailed(binaryExpression.Print(), GetType().Name));
CoreStrings.TranslationFailed(binaryExpression.Print()));
}
}

Expand Down Expand Up @@ -260,7 +260,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
objectArrayProjection = objectArrayProjectionExpression;
break;
default:
throw new InvalidOperationException(CoreStrings.QueryFailed(extensionExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(extensionExpression.Print()));
}

var jArray = _projectionBindings[objectArrayProjection];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
: QueryCompilationContext.NotTranslatedExpression;
}

throw new InvalidOperationException(CoreStrings.QueryFailed(extensionExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(extensionExpression.Print()));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
return _clientEval ? extensionExpression : QueryCompilationContext.NotTranslatedExpression;

default:
throw new InvalidOperationException(CoreStrings.QueryFailed(extensionExpression.Print(), GetType().Name));
throw new InvalidOperationException(CoreStrings.TranslationFailed(extensionExpression.Print()));
}
}

Expand Down
8 changes: 0 additions & 8 deletions src/EFCore/Properties/CoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/EFCore/Properties/CoreStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1233,9 +1233,6 @@
<data name="QueryEntityMaterializationConditionWrongShape" xml:space="preserve">
<value>The materialization condition passed for entity shaper of entity type '{entityType}' is not of the correct shape. A materialization condition must be a 'LambdaExpression' of 'Func&lt;ValueBuffer, IEntityType&gt;'.</value>
</data>
<data name="QueryFailed" xml:space="preserve">
<value>Processing of the LINQ expression '{expression}' by '{visitor}' failed. This may indicate either a bug or a limitation in Entity Framework. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.</value>
</data>
<data name="QueryInvalidMaterializationType" xml:space="preserve">
<value>The query contains a projection '{projection}' of type '{queryableType}'. Collections in the final projection must be an 'IEnumerable&lt;T&gt;' type such as 'List&lt;T&gt;'. Consider using 'ToList' or some other mechanism to convert the 'IQueryable&lt;T&gt;' or 'IOrderedEnumerable&lt;T&gt;' into an 'IEnumerable&lt;T&gt;'.</value>
</data>
Expand Down

0 comments on commit 4dc48f3

Please sign in to comment.