Skip to content

Commit

Permalink
fix(types): handle negative money values (#231)
Browse files Browse the repository at this point in the history
* Update parseMoney to handle negative values

This is to fix a bug where the negative sign is lost for money types.

* Remove unneeded backslash for linter
  • Loading branch information
farant authored and benjie committed Jun 2, 2018
1 parent 657e205 commit 8ed07ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/graphile-build-pg/src/plugins/PgTypesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export default (function PgTypesPlugin(
};

const parseMoney = str => {
const numerical = str.replace(/[^0-9.,]/g, "");
const numerical = str.replace(/[^0-9.,-]/g, "");
const lastCommaIndex = numerical.lastIndexOf(",");
if (lastCommaIndex >= 0 && lastCommaIndex === numerical.length - 3) {
// Assume string is of the form '123.456,78'
Expand Down

0 comments on commit 8ed07ff

Please sign in to comment.