-
Notifications
You must be signed in to change notification settings - Fork 21
fix(expand
): proper subquery from
construction
#1126
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
Conversation
if a query selects from another query, we need to consider the case where the subquery has path expressions (and therefore joins). The best solution is then to drill down into the innermost query of the from clause, because we do not know the depth. It is also not a good idea to check for the `ref` of the innermost _untransformed_ query, as it is potentially a scoped query (as shown in one of the tests). fix #1112
expect(JSON.parse(JSON.stringify(res))).to.deep.equal(expected) | ||
}) | ||
it('expand via subquery with path expressions nested', () => { | ||
const q = cds.ql`SELECT from (SELECT from (SELECT from bookshop.Books as inner { author, ID } where author.name = 'King') as Mid { * }) as Outer { |
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.
btw this revealed another issue, which is not subject to this PR. So I will ship a dedicated fix for #1127 once this is in main
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.
As discussed: might get obsolete with cds9 but would work with that as well
Thanks @patricebender 👍
🤖 I have created a release *beep* *boop* --- <details><summary>db-service: 1.20.0</summary> ## [1.20.0](db-service-v1.19.1...db-service-v1.20.0) (2025-04-17) ### Added * Result set streaming ([#702](#702)) ([2fe02ea](2fe02ea)) ### Fixed * **`expand`:** proper subquery `from` construction ([#1126](#1126)) ([e343e79](e343e79)), closes [#1114](#1114) [#1112](#1112) * Improved support for special characters in column names ([#1141](#1141)) ([ba04697](ba04697)) * **infer:** for localized queries, use `localized.<entity>` as `_target` ([#1140](#1140)) ([b08707b](b08707b)) </details> <details><summary>sqlite: 1.11.0</summary> ## [1.11.0](sqlite-v1.10.0...sqlite-v1.11.0) (2025-04-17) ### Added * Result set streaming ([#702](#702)) ([2fe02ea](2fe02ea)) </details> <details><summary>postgres: 1.14.0</summary> ## [1.14.0](postgres-v1.13.0...postgres-v1.14.0) (2025-04-17) ### Added * Result set streaming ([#702](#702)) ([2fe02ea](2fe02ea)) </details> <details><summary>hana: 1.9.0</summary> ## [1.9.0](hana-v1.8.1...hana-v1.9.0) (2025-04-17) ### Added * enable skip hana wrapping ([#1137](#1137)) ([5e6d61f](5e6d61f)) * Result set streaming ([#702](#702)) ([2fe02ea](2fe02ea)) ### Fixed * Improved support for special characters in column names ([#1141](#1141)) ([ba04697](ba04697)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: D045778 <[email protected]>
) `q._target` will resolve recursively to the innermost entity, with our streamlined `cds.infer` --> no need to do this manually anymore this is a follow up of #1126 @danjoa fyi --------- Co-authored-by: Johannes Vogel <[email protected]>
if a query selects from another query, we need to consider the case where the subquery has path expressions (and therefore joins).
The best solution is then to drill down into the innermost query of the from clause, because we do not know the depth.
It is also not a good idea to check for the
ref
of the innermost untransformed query, as it is potentially a scoped query (as shown in one of the tests).Moreover, it is not possible to use the
ref
of the transformed query because it might be replaced by joinargs
.replaces #1114
fix #1112