-
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
LINQ Any() statement generates invalid SQL #6710
Comments
Skip/Take should not be lifted from the subquery. |
@smitpatel neither should |
@caleblloyd - Would the result be any different in absence/presence of EXISTS (
SELECT 1
FROM `Blogs` AS `m`
ORDER BY `m`.`Id` DESC
LIMIT 10 OFFSET 5
)
EXISTS (
SELECT 1
FROM `Blogs` AS `m`
LIMIT 10 OFFSET 5
) |
@smitpatel it doesn't matter in this case, but I imagine if this query were to end up nested into another query (but the |
@smitpatel additionally, if a caller calls By removing the |
@caleblloyd we got a lot of feedback that people like smaller/more elegant queries. We should not be making them more complicated than necessary to satisfy fringe scenarios like accidentally being able to reuse same cache entry for two different queries. |
@maumar why not submit the query in the form that the caller requests? If they hand EF an The magical query reduction is what is causing bugs like these in the first place. |
MyCAT(A distributed MySQL cluster middleware) does not return records in order, so I suppose this should be fixed. |
@rowanmiller can this get a higher priority? Incorrect generated SQL seems like it should be fixed sooner than later If the issue is programmer burden, I'm happy to take a shot at a PR |
It's in the set of bugs allocated to be fixed in our next release (1.1 has pretty much locked now, so it will be 1.2). @anpete could comment on how feasible this would be as a contribution |
Sending back to triage to discuss where to put the fix. |
Steps to reproduce
Models:
The issue
LINQ queries using
.Any()
are causing an incorrect SQLEXISTS
query to be executed:I'd expect a correct
EXISTS
statement to look more like the query in theCOUNT
statement:Therefore the correct
EXISTS
statement should be something like:Further technical details
EF Core version: 1.0.1
Operating system: Ubuntu 16.04
I am using the Pomelo.EntityFramework.MySql driver (I am a contributor to the project). I believe this issue is present in the
Microsoft.EntityFrameworkCore.Relational
package though and may affect all drivers.The text was updated successfully, but these errors were encountered: