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

fix: Adjust Decimal formatter to always render a whole number #853

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ class HANAService extends SQLService {
Int64: expr => `TO_NVARCHAR(${expr})`,
// Reading decimal as string to not loose precision
Decimal: (expr, elem) => elem?.scale
? `TO_NVARCHAR(${expr}, '9.${''.padEnd(elem.scale, '0')}')`
? `TO_NVARCHAR(${expr}, '0.${''.padEnd(elem.scale, '0')}')`
: `TO_NVARCHAR(${expr})`,

// HANA types
Expand Down
3 changes: 1 addition & 2 deletions test/compliance/SELECT.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const assert = require('assert')
const os = require('os')
const cds = require('../cds.js')

describe('SELECT', () => {
Expand Down Expand Up @@ -827,7 +826,7 @@ describe('SELECT', () => {
})
.filter(a => a)

const noUUIDRefs = ref => cds.builtin.types[ref.element?.type] !== cds.builtin.types.UUID
// const noUUIDRefs = ref => cds.builtin.types[ref.element?.type] !== cds.builtin.types.UUID
const noBooleanRefs = ref => !(cds.builtin.types[ref.element?.type] instanceof cds.builtin.types.boolean.constructor)
const noBinaryRefs = ref => !(cds.builtin.types[ref.element?.type] === cds.builtin.types.Binary || cds.builtin.types[ref.element?.type] === cds.builtin.types.LargeBinary)
const noBlobRefs = ref => noBinaryRefs(ref) && cds.builtin.types[ref.element?.type] !== cds.builtin.types.LargeString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ module.exports = [
{
integer64: '-9223372036854775808',
},
{
decimal: null
},
{
decimal: 0,
'=decimal': '0.0000'
},
{
decimal: 1,
'=decimal': '1.0000'
},
{
decimal: '3.14153',
'=decimal': '3.1415'
Expand Down