-
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: Interpret path passed to Include() and allow partial matches #12737
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-enhancement
Milestone
Comments
See also #12802 |
Design meeting decisions:
|
smitpatel
changed the title
Query: Consider revisiting interpretation of path passed to Include() to allow partial matches
Query: Interprete of path passed to Include() and allow partial matches
Apr 4, 2019
ajcvickers
changed the title
Query: Interprete of path passed to Include() and allow partial matches
Query: Interpret of path passed to Include() and allow partial matches
May 10, 2019
ajcvickers
changed the title
Query: Interpret of path passed to Include() and allow partial matches
Query: Interpret path passed to Include() and allow partial matches
May 10, 2019
The product change has been made for this. Proper test coverage is being tracked by #15368 |
smitpatel
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Jun 5, 2019
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.
type-enhancement
The currently accepted design is that for an Include call to be valid (i.e. not ignored) the starting type of the include path has to appear in the results of the query.
The "accidental design" in 2.0 (and what this issue argues for restoring) is that an Include can still be valid if the starting point ends up not being in the results, as long as other entities reachable through the include path are in the results.
In #12181 (comment) we said:
However after this was reported again in #12678, @smitpatel, @maumar and I discussed and I believe there is enough new data to re-discuss this decision.
Example query (based on #12678):
Note that Include() is called on ChekTemplates, and CheckTemplates (i.e. ct) ends up not being in the results. However, ct.Implementers, which was in the include path, is projected. In EF Core 2.0 the results would include Users (mentioned in the call to ThenInclude). In 2.1 they don't.
Some of the arguments in favor of restoring the 2.0 behavior:
I believe it is intuitive for customers: Even if a formal explanation for the 2.0 behavior requires more words and concepts than the currently accepted design (i.e. it is harder for us to analyze and describe), in practice it can save us from having to explain customers why it does not work in this way... I.e. our currently accepted design has proven not be capable of realizing users' intent in a number of cases.
It allows writing queries that are hard to write in any other way: We have some ideas around how we can enable users to call Include in other parts of the query or even to use some version of Include that allows specifying an arbitrary starting type at any point in the query. But none of these work, and even if we make them work at some point, they will still look more complicated and harder to discover than this behavior. Also, rewriting queries so that you don't use query roots that you are not going to include in the results can also be very difficult.
It shouldn't be much more expensive at runtime: worse case scenario, some Include() calls that are now being ignored (and causing warnings) will stop being ignored and some additional entities that the user intended to load (like User in the example) will be loaded.
From a brief chat with @smitpatel and @maumar this wouldn't be to hard to do, e.g. in 3.0.
The text was updated successfully, but these errors were encountered: