-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 in shaper for complex query with nested collection with ToList for inner collection and later on top level projection #23303
Comments
related to #23205 |
Note: for weak entities model, this query throws different exception:
|
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async)
{
return AssertQuery(
async,
ss => from l1 in ss.Set<Level1>()
orderby l1.Id
let inner = (from l2 in l1.OneToMany_Optional1
where l2.Name != "Foo"
let innerL1s = from innerL1 in ss.Set<Level1>()
where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id)
select innerL1.Name
select innerL1s.ToList()).FirstOrDefault()
select inner,
assertOrder: true,
elementAsserter: (e, a) => AssertCollection(e, a));
} Is in our current tests and works for all providers (Sqlite throws Apply not supported exception). The test looks awfully similar |
@smitpatel the only difference is top level ToList (on inner which is already converted to ToList in the let). Issue happens when processing RelationalCollectionShaper that already has a nested RelationalCollectionShaper. The query that works only has one of these so we don't hit the issue. Shaper for working query:
shaper for failing query:
|
Removing from triage to decide what do we want to do for 6.0 here
In current latest code, we throw exception that parameter source is null. The root cause is the
It is the ToList call in very last line. resultContext.Values[1] seems to have empty list while evaluating PopulateCollection function, not sure what goes wrong afterwards. It shouldn't get contaminated else we would see a lot more errors in the query. Cost of figuring out what is wrong may not be worth iff we remove the redundant ToList. We already have test which works when user specify only 1 So decision to make
|
Note from triage: backlogging to remove the redundant ToList, but as a low-priority fix. |
Revisiting this -> Actually above output was bug in expression printer (already notified authorities). The result of FirstOrDefault in the query is null since the enumerable is empty. And we call ToList on this result so ArgumentNullException is by design here. |
query:
exception:
The text was updated successfully, but these errors were encountered: