-
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
Conditional Order By with collection include generates incorrect SQL #6591
Comments
This is a bug in our |
Oh ok thanks. Do you think it is related to the same thing, because when the query orders by 1, sure it's the column index, but when there's a condition with "order by case...then", which returns 1 or 2 and then sort by those values, it's not about column indexes anymore, as for example http://sqlfiddle.com/#!6/05a45/2, we could return any integer in the case, it would sort on that integer value. Here it's not telling "The ORDER BY position number 3 is out of range of the number of items in the select list." because it's really the value here. |
@smitpatel should this be closed as a dupe of #6145. |
@rowanmiller - This one is different. I tested with Sql Server, as @annayafi said,
The orderby clause references column from |
Steps to reproduce
Quite a simple query with a nested include though:
Knowing that a post has a collection of posttags which themselves own a tag.
The issue
The query can't be materialized because generated sql is wrong:
If you are seeing an exception, include the full exceptions details (message and stack trace).
Generated sql:
Nevertheless, it works as expected with a normal order by, without the condition inside I mean.
Further technical details
EF Core version: (found in project.json or packages.config) 1.0.0 or 1.0.1
Operating system: Win 8
Visual Studio version: (e.g. VS 2013 or n/a) vs 2015
The text was updated successfully, but these errors were encountered: