Skip to content

Commit

Permalink
fix: combination of groupby and orderby (#825)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrice Bender <[email protected]>
  • Loading branch information
johannes-vogel and patricebender authored Oct 15, 2024
1 parent 6306d5c commit 10e0534
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class HANAService extends SQLService {
let curPar = parent
while (curPar) {
if (curPar.SELECT.from?.args?.some(a => a.as === col.ref[0])) {
curPar.SELECT.columns.push({ __proto__: col, ref: col.ref, as })
if (!curPar.SELECT.columns.find(c => c.as === as)) curPar.SELECT.columns.push({ __proto__: col, ref: col.ref, as })
break
} else {
curPar.SELECT.columns.push({ __proto__: col, ref: [curPar.SELECT.parent.as, as], as })
Expand Down
8 changes: 8 additions & 0 deletions test/scenarios/bookshop/read.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ describe('Bookshop - Read', () => {
expect(res.data.value[0].genre.parent.name).to.be.eq('Fiction')
})

test('pseudo expand using groupby and orderby on same column', async () => {
const res = await GET(
'/admin/Books?$apply=groupby((author/name))&$orderby=author/name',
admin,
)
expect(res.data.value.every(row => row.author.name)).to.be.true
})

test('Path expression', async () => {
const q = CQL`SELECT title, author.name as author FROM sap.capire.bookshop.Books where author.name LIKE '%a%'`
const res = await cds.run(q)
Expand Down

0 comments on commit 10e0534

Please sign in to comment.