Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return PostgreSQL decimals as numbers not strings
https://eaflood.atlassian.net/browse/WATER-3906 https://eaflood.atlassian.net/browse/WATER-3927 With our [Add billing_transaction model to water-abstraction-system](#135) change we had our first decimal field. What we didn't realise when we created the migration is that the [pg package](https://www.npmjs.com/package/pg) returns decimals as strings. We've encountered this issue before with BigInt's on the [charging-module-api](https://github.com/DEFRA/sroc-charging-module-api) which is why `db/db.js` has logic to parse the string **pg** returns back into a integer. The root cause is the same. Out of concern about loss of precision the DB values are returned as strings. We know we're not dealing with values where this would be an issue so we can have **pg** implicitly parse the decimal strings into floats. [This post](https://stackoverflow.com/a/39176670/6117745) focuses on the BigInt issue. But the cause and solution are the same for decimals. So, this change ensures when we use [Knex](https://github.com/knex/knex) or [Objection.js](https://github.com/vincit/objection.js) we see floats (numbers) instead of strings.
- Loading branch information