Skip to content

Commit

Permalink
dummy decimal for our POC
Browse files Browse the repository at this point in the history
  • Loading branch information
patricebender committed Jan 23, 2025
1 parent f334fe6 commit c133b03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions test/bookshop/db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ entity Books : managed {
genre : Association to Genres default 10;
stock : Integer;
price : Decimal;
// one of the tests inserts a very big decimal which
// collides with our constraint above :D
dummyDecimal : Decimal;
currency : Currency;
image : LargeBinary @Core.MediaType: 'image/png';
footnotes : array of String;
Expand Down
12 changes: 6 additions & 6 deletions test/scenarios/bookshop/insert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ describe('Bookshop - Insert', () => {

test('big decimals', async () => {
const { Books } = cds.entities('sap.capire.bookshop')

const entry = { ID: 2348, title: 'Moby Dick', price: '12345678901234567890.12345' }
const entry = { ID: 2348, title: 'Moby Dick', dummyDecimal: '12345678901234567890.12345' }
await INSERT(entry).into(Books)

const written = await SELECT('price').from(Books, { ID: 2348 })
if (written.price.indexOf('e+') > -1) {
expect(written.price).to.be.eq('1.23456789012346e+19')
const written = await SELECT('dummyDecimal').from(Books, { ID: 2348 })
if (written.dummyDecimal.indexOf('e+') > -1) {
expect(written.dummyDecimal).to.be.eq('1.23456789012346e+19')
} else {
expect(written.price).to.be.eq(entry.price)
expect(written.dummyDecimal).to.be.eq(entry.dummyDecimal)
}
})
})

0 comments on commit c133b03

Please sign in to comment.