Skip to content

Query: Where clause on optional reference navigation throws exception #6782

Closed

Description

@smitpatel

See test Where_predicate_on_optional_reference_navigation() in ComplexNavigationsQueryTestBase
Error is coming somewhere in QuerySourceUpdater
Exception:

------ Test started: Assembly: Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests.dll ------

Test 'Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests.ComplexNavigationsQuerySqlServerTest.Bug' failed: System.ArgumentException : Expression of type 'Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.ValueBufferShaper' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.IShaper`1[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel.Level2]' of method 'System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor+TransparentIdentifier`2[Microsoft.EntityFrameworkCore.Storage.ValueBuffer,System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel.Level2]]] _GroupJoin[ValueBuffer,Level2,Int32,TransparentIdentifier`2](Microsoft.EntityFrameworkCore.Query.RelationalQueryContext, System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Storage.ValueBuffer], Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.IShaper`1[Microsoft.EntityFrameworkCore.Storage.ValueBuffer], Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.IShaper`1[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel.Level2], System.Func`2[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel.Level2,System.Int32], System.Func`3[Microsoft.EntityFrameworkCore.Storage.ValueBuffer,System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel.Level2],Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor+TransparentIdentifier`2[Microsoft.EntityFrameworkCore.Storage.ValueBuffer,System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel.Level2]]], Microsoft.EntityFrameworkCore.Query.Internal.GroupJoinInclude, Microsoft.EntityFrameworkCore.Query.Internal.GroupJoinInclude)'
    at System.Linq.Expressions.Expression.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi)
    at System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments)
    at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
    at System.Linq.Expressions.MethodCallExpressionN.Rewrite(Expression instance, IList`1 args)
    at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
    Query\RelationalQueryModelVisitor.cs(1033,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.QuerySourceUpdater.VisitMethodCall(MethodCallExpression methodCallExpression)
    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
    at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
    Query\ExpressionVisitors\ExpressionVisitorBase.cs(26,0): at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)
    at System.Linq.Expressions.ExpressionVisitor.VisitAndConvert[T](ReadOnlyCollection`1 nodes, String callerName)
    Query\RelationalQueryModelVisitor.cs(1012,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.QuerySourceUpdater.VisitMethodCall(MethodCallExpression methodCallExpression)
    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
    at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
    Query\ExpressionVisitors\ExpressionVisitorBase.cs(26,0): at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)
    Query\RelationalQueryModelVisitor.cs(949,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.LiftSubQuery(IQuerySource querySource, Expression itemsExpression, Expression expression)
    Query\RelationalQueryModelVisitor.cs(411,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.CompileMainFromClauseExpression(MainFromClause mainFromClause, QueryModel queryModel)
    Query\EntityQueryModelVisitor.cs(740,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel)
    at Remotion.Linq.Clauses.MainFromClause.Accept(IQueryModelVisitor visitor, QueryModel queryModel)
    at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
    Query\EntityQueryModelVisitor.cs(721,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
    Query\RelationalQueryModelVisitor.cs(373,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
    Query\Internal\SqlServerQueryModelVisitor.cs(92,0): at Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
    Query\EntityQueryModelVisitor.cs(259,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
    Storage\Database.cs(67,0): at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel)
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    Query\Internal\QueryCompiler.cs(213,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_0`1.<CompileQuery>b__0()
    Query\Internal\CompiledQueryCache.cs(68,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
    Query\Internal\CompiledQueryCache.cs(45,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
    Query\Internal\QueryCompiler.cs(168,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult](Expression query)
    Query\Internal\QueryCompiler.cs(98,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
    Query\Internal\EntityQueryProvider.cs(57,0): at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
    at Remotion.Linq.QueryableBase`1.GetEnumerator()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    ComplexNavigationsQueryTestBase.cs(3716,0): at Microsoft.EntityFrameworkCore.Specification.Tests.ComplexNavigationsQueryTestBase`2.Bug()
    ComplexNavigationsQuerySqlServerTest.cs(1901,0): at Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests.ComplexNavigationsQuerySqlServerTest.Bug()

0 passed, 1 failed, 0 skipped, took 3.69 seconds (xUnit.net 2.2.0 build 3402).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions