-
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
Add cross join support for Hql and Linq query provider #2327
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and will fallback to an implicit join when the dialect does not support it.
Is this case tested by any CI configurations?
Maybe we should simulate cross join
as inner join
with bogus condition like 1 = 1
. Otherwise queries like #2037 (comment) won't be possible on such dialects.
/// <summary> | ||
/// Does this dialect support CROSS JOIN? | ||
/// </summary> | ||
public virtual bool SupportsCrossJoin => true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be false by default? Otherwise it can be breaking change for some user custom dialects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the same approach Hibernate did with getCrossJoinSeparator which enables cross join by default. If you think that is better to have it disabled by default I will do it, otherwise we can add it as a possible breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with
add it as a possible breaking change.
What about joins generated for associations used in expressions (something like |
No, I will try to update the tests to test both scenarios.
Why not, I will add this fallback.
They are still generated with an implicit join. I tried to use cross join for such scenarios but the code is quite messy and it requires a lot more work as I expected. There are preconditions that such joins always starts with a comma, for example: nhibernate-core/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs Lines 152 to 155 in bf1e116
nhibernate-core/src/NHibernate/SqlCommand/QuerySelect.cs Lines 217 to 225 in ac39173
which are also the root issue for the problem described in #1060:
As this is not trivial to change, I decided to leave it for a separate PR. |
Ok. Got it. So to clarify - did you try to do it globally (both for LINQ and hql)? Won't it be simpler to do just for Linq as a start? |
Yes, the issues that were mentioned are for implementing it globally.
First I have to correct myself, Linq already supports expression like from c in db.Customers join o in db.Orders on c.ContactTitle equals o.Customer.ContactTitle where an implicit join is added for
Now all cross join tests that I found in
The fallback is now added. |
The recent commit also fixes #1128, added a test for that and updated the description. |
Fixes: #1128
Closes #1060
Hql example:
Linq example:
Linq query provider will use cross join when using multiple
from
statements and will fallback to an inner join withon 1=1
, when the dialect does not support it.Possible breaking change:
SupportsCrossJoin
property and set it tofalse
.