-
Notifications
You must be signed in to change notification settings - Fork 934
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
Incorrect SQL when using Contains in Select and Distinct #2054
Comments
If this is a regression, can you tell in which latest version it was working as expected? The trouble comes from NHibernate choosing to evaluate part of the projection in-memory, after execution of the query, while it cannot do that for the order-by and so fully translate it to SQL. But this causes the order-by to be based on an expression which is not part of the select, and since SQL-Server 2008, SQL-Server does no more support having a select distinct with an order-by using expressions which are not also selected. And anyway, it also wrecks the query semantic, since the distinct will no more be applied only to the final expression but also to both of its underlying columns. It looks like we should disable in memory evaluation of projections when a distinct is used. |
Seems like this broke between 4.0.4.4000 and 4.1.1.4000. I thought it broke in 5.x because we are upgrading to 5.x (from 4.0.4.4000), but after some testing it seems this was already broken in 4.1.1.4000. |
Indeed, the issue occurred with #522 because of the |
So that is a regression of 4.1.0. I would rather handle it as just an old bug, which will be just fixed in next minor. |
No.
Yes. |
I'm using LINQ with the MSSQL2012 driver, NHibernate version 5.2.4. Executing below query results in the following exception:
The generated SQL looks is listed below. NHibernate is adding PropertyA and PropertyB in the select, but not in the order by.
I've made a reproduction in linqpad: download
The text was updated successfully, but these errors were encountered: