-
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: Wrong SQL generated for query with group join on a subquery that is not present in the final projection #7003
Comments
This still repros on your current bits. Simplified repro:
|
wrt the second query's order - this happens because we introduce order by key any time we produce left outer join (which under the covers we translate into SelectMany-GroupJoin, and we rely on ordered results to group them correctly). The second orderby was performed on the client because of #4588 (now fixed). in the current bits, for the query without Skip/Take we produce the following:
|
Ok, thanks for your answer. When the new release will fix these issues? |
@hugoterelle Very soon! |
…query that is not present in the final projection Problem was that for GroupJoin we need to mark both inputs for materialization, so we have all the elements necessary to produce joining calls. However, if one side is a subquery, we just mark that outer query source for materialization, without digging deep into the subquery itself. This results in the actual table (which is inside) not being materialized, and that in turn produces SQL which doesn't have necessary elements to produce the correct joins. Fix is to check if the groupjoin element in a subquery, and if so recursively mark it's elements for materialization.
…query that is not present in the final projection Problem was that for GroupJoin we need to mark both inputs for materialization, so we have all the elements necessary to produce joining calls. However, if one side is a subquery, we just mark that outer query source for materialization, without digging deep into the subquery itself. This results in the actual table (which is inside) not being materialized, and that in turn produces SQL which doesn't have necessary elements to produce the correct joins. Fix is to check if the groupjoin element in a subquery, and if so recursively mark it's elements for materialization.
…query that is not present in the final projection Problem was that for GroupJoin we need to mark both inputs for materialization, so we have all the elements necessary to produce joining calls. However, if one side is a subquery, we just mark that outer query source for materialization, without digging deep into the subquery itself. This results in the actual table (which is inside) not being materialized, and that in turn produces SQL which doesn't have necessary elements to produce the correct joins. Fix is to check if the groupjoin element in a subquery, and if so recursively mark it's elements for materialization.
…query that is not present in the final projection Problem was that for GroupJoin we need to mark both inputs for materialization, so we have all the elements necessary to produce joining calls. However, if one side is a subquery, we just mark that outer query source for materialization, without digging deep into the subquery itself. This results in the actual table (which is inside) not being materialized, and that in turn produces SQL which doesn't have necessary elements to produce the correct joins. Fix is to check if the groupjoin element in a subquery, and if so recursively mark it's elements for materialization.
Fixed in f51502f |
Hi,
I have 2 entities with the following code:
Where RootEntity and Entity are
So nothing special. Just a one-to-many relationship between Brand and Smartphone.
The resulting SQL table are:
I try to retrieve my "Smartphone" list with the following parameters:
Here is the LINQ code below:
The issue
Using a SQLite database, the generated SQL is:
When the query is executed by EF, I get the error:
In fact, all columns from 'Smartphone' are duplicated in the SQL Query for the 'Brand' (BrandId, Model, etc.)
Moreover, when I check the SQL query I can see that the ORDER BY is wrong
When I remove the 'Skip(skip)' and 'Take(take)' parameters in the LINQ query, the following SQL query is generated:
This query is executed without errors and gives me the expected result.
But the second problem concerning the ORDER BY remains.
Further technical details
project.json
Operating system: Visual Studio 2015 Update 3
The text was updated successfully, but these errors were encountered: