-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: query modifiers on expand ref
are propagated to subquery
#1049
Conversation
enable the following: ```js cds.ql`SELECT name, books[order by price] { * } FROM Authors` ``` it is still possible to have query modifiers defined as sibling property to `expand`: ```js { ref: ['author'], expand: [ { ref: ['name'], }, ], limit: { offset: { val: 1, }, rows: { val: 1, }, }, orderBy: [ { ref: ['name'], sort: 'asc', }, ], } ``` --> If both are set, the modifiers in the `ref` of the expanded association have precedence
} | ||
const queryModifiers = { ...column, ...ref.at(-1) } | ||
for (const [key, value] of Object.entries(queryModifiers)) { | ||
if (key in { limit: 1, orderBy: 1, groupBy: 1, excluding: 1, where: 1, having: 1 }) subqueryBase[key] = value |
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.
everything covered?
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.
compared with cqn2sql and lgtm.
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.
👍 but you can take out excluding
→ that is always next to expand
or inline
. Also in CQL syntax as supported by the compiler, and hence the CQN produced by it:
cds.ql `SELECT from Authors { ID, name, books[order by title desc limit 1] {*} excluding { descr } }`
⇒ cds.ql {
SELECT: {
from: { ref: [ 'Authors' ] },
columns: [
{ ref: [ 'ID' ] },
{ ref: [ 'name' ] },
{
ref: [
{
id: 'books',
orderBy: [ { ref: [ 'title' ], sort: 'desc' } ],
limit: { rows: { val: 1 } }
}
],
expand: [ '*' ],
excluding: [ 'descr' ]
}
]
}
}
enable the following:
it is still possible to have query modifiers defined as sibling property to
expand
:--> If both are set, the modifiers in the
ref
of the expanded association have precedence