Skip to content
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

perf: Add foreign key indexes to tables #887

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add orderBy for expectational correctness
BobdenOs committed Nov 11, 2024
commit cc7e9223d97b00a4f97999e67b6a995e78cd53c1
20 changes: 10 additions & 10 deletions test/scenarios/bookshop/read.test.js
Original file line number Diff line number Diff line change
@@ -55,10 +55,10 @@ describe('Bookshop - Read', () => {
expect(res.data.value.length).to.be.eq(4) // As there are two books which have the same author
expect(
res.data.value.every(
item =>
'author' in item &&
'ID' in item.author && // foreign key is renamed to element name in target
!('author_ID' in item.author),
item =>
'author' in item &&
'ID' in item.author && // foreign key is renamed to element name in target
!('author_ID' in item.author),
),
).to.be.true
})
@@ -355,18 +355,18 @@ describe('Bookshop - Read', () => {
})

it('allows filtering with between operator', async () => {
const query = SELECT.from('sap.capire.bookshop.Books', ['ID', 'stock']).where ({ stock: { between: 0, and: 100 } })
const query = SELECT.from('sap.capire.bookshop.Books', ['ID', 'stock']).where({ stock: { between: 0, and: 100 } })

return expect((await query).every(row => row.stock >=0 && row.stock <=100)).to.be.true
return expect((await query).every(row => row.stock >= 0 && row.stock <= 100)).to.be.true
})

it('allows various mechanisms for expressing "not in"', async () => {
const results = await cds.db.run([
SELECT.from('sap.capire.bookshop.Books', ['ID']).where({ ID: { 'not in': [201, 251] } }),
SELECT.from('sap.capire.bookshop.Books', ['ID']).where({ ID: { not: { in: [201, 251] } } }),
SELECT.from('sap.capire.bookshop.Books', ['ID']).where('ID not in', [201, 251])
SELECT.from('sap.capire.bookshop.Books', ['ID']).where({ ID: { 'not in': [201, 251] } }).orderBy('ID'),
SELECT.from('sap.capire.bookshop.Books', ['ID']).where({ ID: { not: { in: [201, 251] } } }).orderBy('ID'),
SELECT.from('sap.capire.bookshop.Books', ['ID']).where('ID not in', [201, 251]).orderBy('ID')
])

for (const row of results) expect(row).to.deep.eq([{ID: 207},{ID: 252},{ID: 271}])
for (const result of results) expect(result).to.deep.eq([{ ID: 207 }, { ID: 252 }, { ID: 271 }])
})
})