relq 1.0.123 → 1.0.125

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.
@@ -71,9 +71,11 @@ class PgBase extends relq_base_1.RelqBase {
71
71
  poolErrorHandler;
72
72
  poolConnectHandler;
73
73
  poolRemoveHandler;
74
+ isEdgeRuntime;
74
75
  constructor(schema, config) {
75
76
  super(schema, config);
76
77
  this.environment = (0, environment_detection_1.detectEnvironment)();
78
+ this.isEdgeRuntime = this.environment.type === 'edge';
77
79
  this.usePooling = this.determinePoolingStrategy(config);
78
80
  this.validateConfiguration();
79
81
  this.logEnvironmentInfo();
@@ -135,7 +137,7 @@ class PgBase extends relq_base_1.RelqBase {
135
137
  return await client.query(sql);
136
138
  }
137
139
  finally {
138
- client.release();
140
+ client.release(this.isEdgeRuntime);
139
141
  }
140
142
  }
141
143
  else if (this.client) {
@@ -16,6 +16,8 @@ function toPoolConfig(config) {
16
16
  const port = config.aws?.port ?? config.port ?? 5432;
17
17
  const user = config.aws?.user ?? config.user ?? (isAws ? 'admin' : undefined);
18
18
  const ssl = isAws ? (config.aws.ssl ?? true) : config.ssl;
19
+ const isWorkers = typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers';
20
+ const allowExitOnIdle = !isWorkers;
19
21
  const poolConfig = {
20
22
  host,
21
23
  port,
@@ -28,7 +30,7 @@ function toPoolConfig(config) {
28
30
  connectionTimeoutMillis: config.pool?.connectionTimeoutMillis ?? smartDefaults.connectionTimeoutMillis,
29
31
  application_name: config.pool?.application_name,
30
32
  ssl: config.pool?.ssl ?? ssl,
31
- allowExitOnIdle: true
33
+ allowExitOnIdle
32
34
  };
33
35
  if (config.connectionString) {
34
36
  return {
@@ -39,7 +41,7 @@ function toPoolConfig(config) {
39
41
  connectionTimeoutMillis: poolConfig.connectionTimeoutMillis,
40
42
  application_name: poolConfig.application_name,
41
43
  ssl: poolConfig.ssl,
42
- allowExitOnIdle: true
44
+ allowExitOnIdle
43
45
  };
44
46
  }
45
47
  return poolConfig;
@@ -34,9 +34,11 @@ export class PgBase extends RelqBase {
34
34
  poolErrorHandler;
35
35
  poolConnectHandler;
36
36
  poolRemoveHandler;
37
+ isEdgeRuntime;
37
38
  constructor(schema, config) {
38
39
  super(schema, config);
39
40
  this.environment = detectEnvironment();
41
+ this.isEdgeRuntime = this.environment.type === 'edge';
40
42
  this.usePooling = this.determinePoolingStrategy(config);
41
43
  this.validateConfiguration();
42
44
  this.logEnvironmentInfo();
@@ -98,7 +100,7 @@ export class PgBase extends RelqBase {
98
100
  return await client.query(sql);
99
101
  }
100
102
  finally {
101
- client.release();
103
+ client.release(this.isEdgeRuntime);
102
104
  }
103
105
  }
104
106
  else if (this.client) {
@@ -11,6 +11,8 @@ export function toPoolConfig(config) {
11
11
  const port = config.aws?.port ?? config.port ?? 5432;
12
12
  const user = config.aws?.user ?? config.user ?? (isAws ? 'admin' : undefined);
13
13
  const ssl = isAws ? (config.aws.ssl ?? true) : config.ssl;
14
+ const isWorkers = typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers';
15
+ const allowExitOnIdle = !isWorkers;
14
16
  const poolConfig = {
15
17
  host,
16
18
  port,
@@ -23,7 +25,7 @@ export function toPoolConfig(config) {
23
25
  connectionTimeoutMillis: config.pool?.connectionTimeoutMillis ?? smartDefaults.connectionTimeoutMillis,
24
26
  application_name: config.pool?.application_name,
25
27
  ssl: config.pool?.ssl ?? ssl,
26
- allowExitOnIdle: true
28
+ allowExitOnIdle
27
29
  };
28
30
  if (config.connectionString) {
29
31
  return {
@@ -34,7 +36,7 @@ export function toPoolConfig(config) {
34
36
  connectionTimeoutMillis: poolConfig.connectionTimeoutMillis,
35
37
  application_name: poolConfig.application_name,
36
38
  ssl: poolConfig.ssl,
37
- allowExitOnIdle: true
39
+ allowExitOnIdle
38
40
  };
39
41
  }
40
42
  return poolConfig;
package/dist/index.d.ts CHANGED
@@ -5004,6 +5004,8 @@ declare abstract class PgBase<TSchema = any> extends RelqBase<TSchema> {
5004
5004
  protected poolErrorHandler?: (err: Error) => void;
5005
5005
  protected poolConnectHandler?: () => void;
5006
5006
  protected poolRemoveHandler?: () => void;
5007
+ /** Whether we're running in an edge runtime (Cloudflare Workers, etc.) */
5008
+ protected readonly isEdgeRuntime: boolean;
5007
5009
  constructor(schema: TSchema, config: RelqConfig);
5008
5010
  protected _initialize(): Promise<void>;
5009
5011
  protected _query(sql: string): Promise<DriverQueryResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relq",
3
- "version": "1.0.123",
3
+ "version": "1.0.125",
4
4
  "description": "The Fully-Typed PostgreSQL ORM for TypeScript",
5
5
  "author": "Olajide Mathew O. <olajide.mathew@yuniq.solutions>",
6
6
  "license": "MIT",