Add support for joining a subquery in hql#2551
Conversation
364f63d to
8ade292
Compare
8ade292 to
3e5261d
Compare
| l++; | ||
| } | ||
|
|
||
| subclassPropertyAliases[propName] = aliases; |
There was a problem hiding this comment.
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. |
fredericDelaporte
left a comment
There was a problem hiding this comment.
I have not reviewed the SelectClause changes. I lack knowledge of how it works there.
Co-authored-by: Frédéric Delaporte <12201973+fredericDelaporte@users.noreply.github.com>
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.
@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.
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
Includemethod on all databases when paging results. SqlINoperator 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