Skip to content

Commit

Permalink
chore: use ieee754compatible instead of string_decimals (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans authored Jul 2, 2024
1 parent 3f350d1 commit ccff259
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion postgres/lib/PostgresService.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ GROUP BY k
Int64: expr => `cast(${expr} as varchar)`,
// REVISIT: always cast to string in next major
// Reading decimal as string to not loose precision
Decimal: cds.env.features.string_decimals ? expr => `cast(${expr} as varchar)` : undefined,
Decimal: cds.env.features.ieee754compatible ? expr => `cast(${expr} as varchar)` : undefined,

// Convert point back to json format
'cds.hana.ST_POINT': expr => `CASE WHEN (${expr}) IS NOT NULL THEN json_object('x':(${expr})[0],'y':(${expr})[1])::varchar END`,
Expand Down
4 changes: 2 additions & 2 deletions postgres/test/ql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ describe('QL to PostgreSQL', () => {
.where({ abv: { '>': 1.0 } })
.orderBy({ abv: 'desc' }),
)
expect(beers[0].abv).to.equal(cds.env.features.string_decimals ? "5.9" : 5.9)
expect(beers[0].abv).to.equal(cds.env.features.ieee754compatible ? "5.9" : 5.9)
const reverseBeers = await cds.run(
SELECT.from(Beers)
.where({ abv: { '>': 1.0 } })
.orderBy({ abv: 'asc' }),
)
expect(reverseBeers[0].abv).to.equal(cds.env.features.string_decimals ? "4.9" : 4.9)
expect(reverseBeers[0].abv).to.equal(cds.env.features.ieee754compatible ? "4.9" : 4.9)
})

test('-> with groupBy', async () => {
Expand Down
2 changes: 1 addition & 1 deletion sqlite/lib/SQLiteService.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class SQLiteService extends SQLService {
Int64: expr => `CAST(${expr} as TEXT)`,
// REVISIT: always cast to string in next major
// Reading decimal as string to not loose precision
Decimal: cds.env.features.string_decimals ? expr => `CAST(${expr} as TEXT)` : undefined,
Decimal: cds.env.features.ieee754compatible ? expr => `CAST(${expr} as TEXT)` : undefined,
// Binary is not allowed in json objects
Binary: expr => `${expr} || ''`,
}
Expand Down
1 change: 0 additions & 1 deletion test/bookshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
},
"features": {
"odata_new_adapter": true,
"string_decimals": true,
"ieee754compatible": true
}
}
Expand Down
1 change: 0 additions & 1 deletion test/compliance/resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
}
},
"features": {
"string_decimals": true,
"ieee754compatible": true
}
}
Expand Down

0 comments on commit ccff259

Please sign in to comment.