From 8ed07ff561fb560f719b2c662b74042e9ac0da59 Mon Sep 17 00:00:00 2001 From: farant Date: Sat, 2 Jun 2018 11:56:22 -0400 Subject: [PATCH] fix(types): handle negative money values (#231) * 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 --- packages/graphile-build-pg/src/plugins/PgTypesPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphile-build-pg/src/plugins/PgTypesPlugin.js b/packages/graphile-build-pg/src/plugins/PgTypesPlugin.js index 9613699d4..d43a88018 100644 --- a/packages/graphile-build-pg/src/plugins/PgTypesPlugin.js +++ b/packages/graphile-build-pg/src/plugins/PgTypesPlugin.js @@ -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'