-
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
Invalid SQL created for some joins in a subquery #3465
Comments
It does not look like there is other reports for this as of now. Have you been able to elaborate a test case? |
@fredericDelaporte - sorry, I have not had the time to do so. I will try to put something minimal together next week. |
My guess would be that this might be related to: #3369 But I'm not entirely sure without digging further. |
Ok, the repro is actually much simpler than I had originally thought. An anonymized query, but this will do the trick:
Where "e.Entities" is mapped as a set (or probably any other type of collection) on EntityA It seems that multiple items in a select list in exists after the initial collection are ignored. |
And that example works in 5.4.x and fails in 5.5.x? Or does it just not include the (unneeded) join on EntityB? If that is the later, it would be better to have an actually failing test case on 5.5 but succeeding on 5.4.x. Can you also provide the example class definition? We have too little information from your example to know maybe relevant details. The set belonging to EntityA contains what? Other EntityA, or EntityB, or something else? |
@fredericDelaporte - here are some additional details that should help. Consider the following mappings:
When this hql query is executed:
5.4.6 produces:
5.5.0 produces:
I hope this helps - let me know if I can provide any further info! |
7cd90cc adds the corresponding test case. It does fail when cherry-picked on 3875011 (#3369 commit). But it does not fail when cherry-picked on the previous commit, 0fdb589. The #3369 change here is the culprit: nhibernate-core/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs Lines 719 to 722 in 07c367f
It does add the node as a from element even when it is already from a from. I propose a fix in #3476. |
Fixed by #3476. |
I have found what appears to be a regression in the 5.5.0 release (this worked fine previously with 5.4.6.
The mappings are rather complex, so I'll do my best to explain here:
The hql fragment causing the issue is as follows:
This generates the following sql which is invalid:
As you can see "scheduleda3_" is never included in the from statement, and a join for "activity4_" is never generated either.
I'm not sure what details may be relevant here, other than to say that ScheduledActivityShift is a subclass of ActivityShift, which is directly referenced in the ActivityShiftAssignment entity. I used the implicit join in order to access some of the subclass-specific properties previously.
I can attempt to create a minimal test case, but wanted to put this out there first in case others (with simpler mappings) have encountered the same issue.
The text was updated successfully, but these errors were encountered: