Merge pull request #324 from MikhailGoncharov/service-api-read-no-keys-if-not-asked

Fixed eagerly read IDs (CAP !== OData)
This commit is contained in:
Heiko Witteborg
2022-02-17 08:53:01 +01:00
committed by GitHub
2 changed files with 55 additions and 0 deletions

View File

@@ -32,6 +32,27 @@ describe('Consuming Services locally', () => {
})
})
}).where(`name like`, 'E%')
if (cds.version >= '5.9.0') {
expect(authors).to.containSubset([
{
name: 'Emily Brontë',
books: [
{
title: 'Wuthering Heights',
currency: { name: 'British Pound', symbol: '£' },
},
],
},
{
name: 'Edgar Allen Poe',
books: [
{ title: 'The Raven', currency: { name: 'US Dollar', symbol: '$' } },
{ title: 'Eleonora', currency: { name: 'US Dollar', symbol: '$' } },
],
},
])
return
}
expect(authors).to.containSubset([
{
name: 'Emily Brontë',

View File

@@ -35,6 +35,21 @@ describe('Hierarchical Data', ()=>{
))
it ('supports nested reads', async()=>{
if (cds.version >= '5.9.0') {
expect (await
SELECT.one.from (Cats, c=>{
c.ID, c.name.as('parent'), c.children (c=>{
c.name.as('child')
})
}) .where ({name:'Cat'})
) .to.eql (
{ ID:101, parent:'Cat', children:[
{ child:'Kitty' },
{ child:'Catwoman' },
]}
)
return
}
expect (await
SELECT.one.from (Cats, c=>{
c.ID, c.name.as('parent'), c.children (c=>{
@@ -50,6 +65,25 @@ describe('Hierarchical Data', ()=>{
})
it ('supports deeply nested reads', async()=>{
if (cds.version >= '5.9.0') {
expect (await SELECT.one.from (Cats, c=>{
c.ID, c.name, c.children (
c => { c.name },
{levels:3}
)
}) .where ({name:'Cat'})
) .to.eql (
{ ID:101, name:'Cat', children:[
{ name:'Kitty', children:[
{ name:'Kitty Cat', children:[
{ name:'Aristocat' }, ]}, // level 3
{ name:'Kitty Bat', children:[] }, ]},
{ name:'Catwoman', children:[
{ name:'Catalina', children:[] } ]},
]}
)
return
}
expect (await SELECT.one.from (Cats, c=>{
c.ID, c.name, c.children (
c => { c.name },