Cosmos: remove automatic composition of discriminator filter in raw SQL queries #26292
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #26124
Description
When executing a Cosmos raw SQL query, EF Core automatically appends the discriminator filter corresponding to the DbSet queried. If the discriminator projected by the user doesn't correspond to it, no rows are return. This PR removes the automatic discriminator filter, causing an exception to be thrown instead by the materializer.
Customer impact
If the user forgets to project out a discriminator in a Cosmos raw SQL, currently no rows at all are returned by the query (rather than throwing an exception). This is a case of incorrect results which is somewhat hard to diagnose.
How found
Flagged by @JeremyLikness in #26124
Regression
No, Cosmos FromSql is a new feature introduced in 6.0.
Testing
Yes, introduced in this PR.
Risk
Low, the fix is trivial and affects a new feature (FromSql)