@prisma/adapter-pg 7.11.0-dev.3 → 7.11.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -325,13 +325,16 @@ function normalize_timez(time) {
325
325
  const pad = (n) => String(n).padStart(2, "0");
326
326
  return `${pad(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}${fraction}`;
327
327
  }
328
+ var SUPPORTED_MONEY_FORMAT = /^(?:(-)[\p{L}\p{Sc}]+|[\p{L}\p{Sc}]+(-)?)(\d{1,3}(?:,\d{3})*)(\.(?!\d{3}$)\d+)?$/u;
328
329
  function normalize_money(money) {
329
- if (!/^-?\$\d{1,3}(,\d{3})*\.\d{2}$/.test(money)) {
330
+ const match = SUPPORTED_MONEY_FORMAT.exec(money);
331
+ if (match === null) {
330
332
  throw new Error(
331
- `Unsupported money format "${money}": only the default lc_monetary format, such as -$1,234.50, is supported`
333
+ `Unsupported money format "${money}": expected a currency symbol directly followed by an amount with "," thousands separators and a "." decimal point, such as -\xA31,234.50`
332
334
  );
333
335
  }
334
- return money.replace(/[^\d.-]/g, "");
336
+ const [, signBeforeSymbol = "", signAfterSymbol = "", integer, fraction = ""] = match;
337
+ return `${signBeforeSymbol}${signAfterSymbol}${integer.replaceAll(",", "")}${fraction}`;
335
338
  }
336
339
  function normalize_xml(xml) {
337
340
  return xml;
package/dist/index.mjs CHANGED
@@ -289,13 +289,16 @@ function normalize_timez(time) {
289
289
  const pad = (n) => String(n).padStart(2, "0");
290
290
  return `${pad(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}${fraction}`;
291
291
  }
292
+ var SUPPORTED_MONEY_FORMAT = /^(?:(-)[\p{L}\p{Sc}]+|[\p{L}\p{Sc}]+(-)?)(\d{1,3}(?:,\d{3})*)(\.(?!\d{3}$)\d+)?$/u;
292
293
  function normalize_money(money) {
293
- if (!/^-?\$\d{1,3}(,\d{3})*\.\d{2}$/.test(money)) {
294
+ const match = SUPPORTED_MONEY_FORMAT.exec(money);
295
+ if (match === null) {
294
296
  throw new Error(
295
- `Unsupported money format "${money}": only the default lc_monetary format, such as -$1,234.50, is supported`
297
+ `Unsupported money format "${money}": expected a currency symbol directly followed by an amount with "," thousands separators and a "." decimal point, such as -\xA31,234.50`
296
298
  );
297
299
  }
298
- return money.replace(/[^\d.-]/g, "");
300
+ const [, signBeforeSymbol = "", signAfterSymbol = "", integer, fraction = ""] = match;
301
+ return `${signBeforeSymbol}${signAfterSymbol}${integer.replaceAll(",", "")}${fraction}`;
299
302
  }
300
303
  function normalize_xml(xml) {
301
304
  return xml;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-pg",
3
- "version": "7.11.0-dev.3",
3
+ "version": "7.11.0-dev.5",
4
4
  "description": "Prisma's driver adapter for \"pg\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -34,10 +34,10 @@
34
34
  "pg": "^8.16.3",
35
35
  "postgres-array": "3.0.4",
36
36
  "@types/pg": "^8.16.0",
37
- "@prisma/driver-adapter-utils": "7.11.0-dev.3"
37
+ "@prisma/driver-adapter-utils": "7.11.0-dev.5"
38
38
  },
39
39
  "devDependencies": {
40
- "@prisma/debug": "7.11.0-dev.3"
40
+ "@prisma/debug": "7.11.0-dev.5"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "DEV=true tsx helpers/build.ts",