Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: compilation error (NRE during sql gen) for complex query with join, skip, take, orderby and select constant in row number paging scenario #12574

Closed
maumar opened this issue Jul 5, 2018 · 0 comments · Fixed by #17766
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 5, 2018

query using Northwind model (rownumber paging)

var query = (from c in ctx.Customers
			 join o in ctx.Orders on c.CustomerID equals o.CustomerID
			 orderby o.OrderID
			 select new
			 {
				 c.ContactName,
				 o.OrderID
			 }).Skip(10).Take(5).Select(e => "Foo");

var result = query.ToList();

Exception:

System.NullReferenceException : Object reference not set to an instance of an object.
	at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitSelect(SelectExpression selectExpression)
	at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Accept(ExpressionVisitor visitor)
	at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit(Expression expression)
	at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.<GenerateList>b__58_0(Expression e)
	at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.GenerateList[T](IReadOnlyList`1 items, Action`1 generationAction, Action`1 joinAction)
	at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.GenerateList(IReadOnlyList`1 items, Action`1 joinAction)
	at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitSelect(SelectExpression selectExpression)
	at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Accept(ExpressionVisitor visitor)
	at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit(Expression expression)
	at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.GenerateSql(IReadOnlyDictionary`2 parameterValues)
	at Microsoft.EntityFrameworkCore.Query.Internal.RelationalExpressionPrinter.CommandBuilderPrinter.TryPrintConstant(ConstantExpression constantExpression, IndentedStringBuilder stringBuilder, Boolean removeFormatting)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitConstant(ConstantExpression constantExpression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitMethodCall(MethodCallExpression methodCallExpression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitMethodCall(MethodCallExpression methodCallExpression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitLambda[T](Expression`1 lambdaExpression)
	at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
	at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.PrintInternal(Expression expression, Boolean removeFormatting, Nullable`1 characterLimit, Boolean highlightNonreducibleNodes, Boolean reduceBeforePrinting, Boolean generateUniqueQsreIds, Boolean printConnections)
	at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Print(Expression expression, Boolean removeFormatting, Nullable`1 characterLimit, Boolean printConnections)
	at Microsoft.EntityFrameworkCore.Internal.CoreLoggerExtensions.QueryExecutionPlanned(IDiagnosticsLogger`1 diagnostics, IExpressionPrinter expressionPrinter, Expression queryExecutorExpression)
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateExecutorLambda[TResults]()
	at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.CreateExecutorLambda[TResults]()
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
	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()
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
	at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
	at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
	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)
	at Microsoft.EntityFrameworkCore.Query.SimpleQueryTestBase`1.Join_Customers_Orders_Skip_Take(Boolean isAsync)
	at Microsoft.EntityFrameworkCore.Query.RowNumberPagingTest.<>n__3(Boolean isAsync)
	at Microsoft.EntityFrameworkCore.Query.RowNumberPagingTest.<Join_Customers_Orders_Skip_Take>d__5.MoveNext()
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

SelectExpression is marked as ProjectStar, but it's ProjectStarTable is null

@ajcvickers ajcvickers added this to the 2.2.0 milestone Jul 6, 2018
@ajcvickers ajcvickers modified the milestones: 2.2.0, 3.0.0 Aug 3, 2018
@smitpatel smitpatel added the verify-fixed This issue is likely fixed in new query pipeline. label Jun 5, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0, Backlog Jun 28, 2019
@smitpatel smitpatel removed their assignment Aug 7, 2019
@ajcvickers ajcvickers modified the milestones: Backlog, 3.1.0 Sep 4, 2019
@smitpatel smitpatel removed the verify-fixed This issue is likely fixed in new query pipeline. label Sep 10, 2019
@smitpatel smitpatel self-assigned this Sep 10, 2019
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 10, 2019
@smitpatel smitpatel modified the milestones: 3.1.0, 3.0.0 Sep 10, 2019
smitpatel added a commit that referenced this issue Sep 11, 2019
Covers EFCore.Specs.Tests Query folder

Resolves #8366
Resolves #8582
Resolves #8722
Resolves #9007
Resolves #9254
Resolves #12574
Resolves #12579
Resolves #12598
Resolves #12786
Resolves #12787
Resolves #12794
Resolves #12806
Resolves #12827
Resolves #12873
Resolves #14900
Resolves #15862
Resolves #16157
Resolves #17240
Resolves #17243


Close #12889
Close #17243
smitpatel added a commit that referenced this issue Sep 11, 2019
Covers EFCore.Specs.Tests Query folder

Resolves #8366
Resolves #8582
Resolves #8722
Resolves #9007
Resolves #9254
Resolves #12574
Resolves #12579
Resolves #12598
Resolves #12786
Resolves #12787
Resolves #12794
Resolves #12806
Resolves #12827
Resolves #12873
Resolves #14900
Resolves #15862
Resolves #16157
Resolves #17240


Close #12889
Close #17243
smitpatel added a commit that referenced this issue Sep 11, 2019
Covers EFCore.Specs.Tests Query folder

Resolves #8366
Resolves #8582
Resolves #8722
Resolves #9007
Resolves #9254
Resolves #12574
Resolves #12579
Resolves #12598
Resolves #12786
Resolves #12787
Resolves #12794
Resolves #12806
Resolves #12827
Resolves #12873
Resolves #14900
Resolves #15862
Resolves #16157
Resolves #17240


Close #12889
Close #17243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants