Skip to content

Commit

Permalink
fix: Fix expand aliasing (#959)
Browse files Browse the repository at this point in the history
fixes: #948
  • Loading branch information
BobdenOs authored Dec 19, 2024
1 parent c2b3fbb commit f39097c
Show file tree
Hide file tree
Showing 2 changed files with 11 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 @@ -446,7 +446,7 @@ class HANAService extends SQLService {
? [
{
func: 'concat',
args: [{ ref: ['_parent_path_'] }, { val: `].${q.element.name}[`, param: false }],
args: [{ ref: ['_parent_path_'] }, { val: `].${alias}[`, param: false }],
},
{ func: 'lpad', args: [{ ref: ['$$RN$$'] }, { val: 6, param: false }, { val: '0', param: false }] },
]
Expand Down
10 changes: 10 additions & 0 deletions test/scenarios/bookshop/read.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ describe('Bookshop - Read', () => {
expect(res.data.author.books.length).to.be.eq(2)
})

test('Expand Book with alias', async () => {
const { Books } = cds.entities('sap.capire.bookshop')
const res = await SELECT.one`ID as i, title as t, author as a { name as n, books as b { title as t } }`.from`${Books}[ID=252]`

expect(res.i).to.be.eq(252)
expect(res.t).to.be.eq('Eleonora')
expect(res.a.n).to.be.eq('Edgar Allen Poe')
expect(res.a.b.length).to.be.eq(2)
})

test.skip('Expand Book($count,$top,$orderby)', async () => {
// REVISIT: requires changes in @sap/cds to allow $count inside expands
const res = await GET(
Expand Down

0 comments on commit f39097c

Please sign in to comment.