-
Notifications
You must be signed in to change notification settings - Fork 932
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 support for joining a subquery in hql #2551
Conversation
364f63d
to
8ade292
Compare
8ade292
to
3e5261d
Compare
} | ||
|
||
subclassPropertyAliases[propName] = aliases; |
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.
Now subclassPropertyAliases
contains also component properties which are needed in order to select component properties from a subquery.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
And your alias related changes seem to fix issue reported here: I see no duplicates in generated SQL |
With the last commit the issue is fixed. |
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 have not reviewed the SelectClause changes. I lack knowledge of how it works there.
Co-authored-by: Frédéric Delaporte <[email protected]>
b1cefc3
to
cd082f5
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
11126a8
to
bad7081
Compare
} | ||
|
||
var node = (IASTNode) e; | ||
if (processedElements.Add(fromElement)) |
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.
@maca88, this causes #3489 regression.
The query is
insert into Enrolment (Course, Student)
select e.Course, e.Student from Enrolment e
At the second column, the from is already added, causing the execution to go into the else and not rendering the second column.
In debug, forcing the execution to jump directly to RenderNonScalarIdentifiers
(so, not adding again the from to combinedFromElements) allows the test to succeed.
But surely the fix is not as simple as throwing away the else in all cases with something like:
if (processedElements.Add(fromElement))
{
combinedFromElements.Add(fromElement);
}
RenderNonScalarIdentifiers(fromElement, inheritedExpressions.ContainsKey(e) ? null : e, appender);
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.
Doing that change seems to break only HqlDuplicateEntitySelectionSubQuery
which looks like testing invalid cases, containing duplicated selection of entities. Why should we support theses cases?
Basic hql syntax:
In case the subquery returns multiple values, each value can be referenced by using an alias:
Aliases can be nested in case of nested subqueries:
This feature is a requirement in order to support the
Include
method on all databases when paging results. SqlIN
operator does not work with composite keys and in some databases even for normal keys (e.g. MySql), so with this feature we can write the following query:Known limitation:
Also fixes #2092