@prisma/adapter-pg 7.11.0-dev.2 → 7.11.0-dev.4

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.d.mts CHANGED
@@ -57,11 +57,11 @@ declare class PrismaPgAdapter extends PgQueryable<StdClient> implements SqlDrive
57
57
 
58
58
  declare type PrismaPgOptions = {
59
59
  /**
60
- * The name of the schema to use in generated queries. When the adapter creates the pool itself
61
- * (i.e. it is given a config object or a connection string), it also sets the `search_path` of
62
- * every connection to this schema, so that raw queries resolve unqualified table names in this
63
- * schema, unless the config's `options` already set a `search_path`. Externally provided pools are left untouched; configure the search path on the pool
64
- * itself in that case, e.g. via `options: '-c search_path="mySchema"'`.
60
+ * The name of the schema to use in generated queries. Raw queries are not affected: they resolve
61
+ * unqualified names through the connection's `search_path`. Qualify the name in raw SQL
62
+ * (`"mySchema"."User"`), or set the search path on the database role
63
+ * (`ALTER ROLE ... SET search_path = ...`). The adapter does not set it itself, because behind a
64
+ * connection pooler in transaction mode a session setting is shared with the pooler's other clients.
65
65
  */
66
66
  schema?: string;
67
67
  /**
package/dist/index.d.ts CHANGED
@@ -57,11 +57,11 @@ declare class PrismaPgAdapter extends PgQueryable<StdClient> implements SqlDrive
57
57
 
58
58
  declare type PrismaPgOptions = {
59
59
  /**
60
- * The name of the schema to use in generated queries. When the adapter creates the pool itself
61
- * (i.e. it is given a config object or a connection string), it also sets the `search_path` of
62
- * every connection to this schema, so that raw queries resolve unqualified table names in this
63
- * schema, unless the config's `options` already set a `search_path`. Externally provided pools are left untouched; configure the search path on the pool
64
- * itself in that case, e.g. via `options: '-c search_path="mySchema"'`.
60
+ * The name of the schema to use in generated queries. Raw queries are not affected: they resolve
61
+ * unqualified names through the connection's `search_path`. Qualify the name in raw SQL
62
+ * (`"mySchema"."User"`), or set the search path on the database role
63
+ * (`ALTER ROLE ... SET search_path = ...`). The adapter does not set it itself, because behind a
64
+ * connection pooler in transaction mode a session setting is shared with the pooler's other clients.
65
65
  */
66
66
  schema?: string;
67
67
  /**
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;
@@ -860,12 +863,7 @@ var PrismaPgAdapterFactory = class {
860
863
  config;
861
864
  externalPool;
862
865
  async connect() {
863
- const client = this.externalPool ?? new import_pg2.default.Pool(withSearchPath(this.config, this.options?.schema));
864
- if (this.externalPool !== null && this.options?.schema !== void 0) {
865
- debug(
866
- `The search path is not set on externally provided pools, schema "${this.options.schema}" is only used for generated queries. Set the search path on the pool itself if raw queries need it.`
867
- );
868
- }
866
+ const client = this.externalPool ?? new import_pg2.default.Pool(this.config);
869
867
  const onIdleClientError = (err) => {
870
868
  debug(`Error from idle pool client: ${err.message} %O`, err);
871
869
  this.options?.onPoolError?.(err);
@@ -895,28 +893,6 @@ var PrismaPgAdapterFactory = class {
895
893
  });
896
894
  }
897
895
  };
898
- function withSearchPath(config, schema) {
899
- if (schema === void 0 || setsSearchPath(config.options)) {
900
- return config;
901
- }
902
- const searchPath = `-c search_path=${escapeOptionValue(quoteIdentifierIfNeeded(schema))},public`;
903
- return {
904
- ...config,
905
- options: config.options ? `${config.options} ${searchPath}` : searchPath
906
- };
907
- }
908
- function setsSearchPath(options) {
909
- return options !== void 0 && /(?:^|\s)(?:-c\s*|--)search[_-]path=/i.test(options);
910
- }
911
- function quoteIdentifierIfNeeded(name2) {
912
- if (/^[a-z_][a-z0-9_$]*$/.test(name2)) {
913
- return name2;
914
- }
915
- return `"${name2.replaceAll('"', '""')}"`;
916
- }
917
- function escapeOptionValue(value) {
918
- return value.replace(/[\\\s]/g, (char) => `\\${char}`);
919
- }
920
896
  // Annotate the CommonJS export names for ESM import in node:
921
897
  0 && (module.exports = {
922
898
  PrismaPg
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;
@@ -824,12 +827,7 @@ var PrismaPgAdapterFactory = class {
824
827
  config;
825
828
  externalPool;
826
829
  async connect() {
827
- const client = this.externalPool ?? new pg2.Pool(withSearchPath(this.config, this.options?.schema));
828
- if (this.externalPool !== null && this.options?.schema !== void 0) {
829
- debug(
830
- `The search path is not set on externally provided pools, schema "${this.options.schema}" is only used for generated queries. Set the search path on the pool itself if raw queries need it.`
831
- );
832
- }
830
+ const client = this.externalPool ?? new pg2.Pool(this.config);
833
831
  const onIdleClientError = (err) => {
834
832
  debug(`Error from idle pool client: ${err.message} %O`, err);
835
833
  this.options?.onPoolError?.(err);
@@ -859,28 +857,6 @@ var PrismaPgAdapterFactory = class {
859
857
  });
860
858
  }
861
859
  };
862
- function withSearchPath(config, schema) {
863
- if (schema === void 0 || setsSearchPath(config.options)) {
864
- return config;
865
- }
866
- const searchPath = `-c search_path=${escapeOptionValue(quoteIdentifierIfNeeded(schema))},public`;
867
- return {
868
- ...config,
869
- options: config.options ? `${config.options} ${searchPath}` : searchPath
870
- };
871
- }
872
- function setsSearchPath(options) {
873
- return options !== void 0 && /(?:^|\s)(?:-c\s*|--)search[_-]path=/i.test(options);
874
- }
875
- function quoteIdentifierIfNeeded(name2) {
876
- if (/^[a-z_][a-z0-9_$]*$/.test(name2)) {
877
- return name2;
878
- }
879
- return `"${name2.replaceAll('"', '""')}"`;
880
- }
881
- function escapeOptionValue(value) {
882
- return value.replace(/[\\\s]/g, (char) => `\\${char}`);
883
- }
884
860
  export {
885
861
  PrismaPgAdapterFactory as PrismaPg
886
862
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-pg",
3
- "version": "7.11.0-dev.2",
3
+ "version": "7.11.0-dev.4",
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.2"
37
+ "@prisma/driver-adapter-utils": "7.11.0-dev.4"
38
38
  },
39
39
  "devDependencies": {
40
- "@prisma/debug": "7.11.0-dev.2"
40
+ "@prisma/debug": "7.11.0-dev.4"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "DEV=true tsx helpers/build.ts",