@pi-r/postgres 0.6.3 → 0.6.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/client/index.d.ts +2 -1
- package/client/index.js +4 -1
- package/package.json +3 -3
package/client/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IDb } from '@e-mc/types/lib';
|
|
2
|
-
import type { PostgresCredential, PostgresDataSource } from '@e-mc/types/lib/db';
|
|
3
2
|
|
|
4
3
|
import type { IDbSourceClient } from '@e-mc/db/types';
|
|
5
4
|
|
|
5
|
+
import type { PostgresCredential, PostgresDataSource } from '../types';
|
|
6
|
+
|
|
6
7
|
declare const Postgres: IDbSourceClient<PostgresDataSource> & {
|
|
7
8
|
setAuthentication(this: IDb, credential: PostgresCredential): void;
|
|
8
9
|
};
|
package/client/index.js
CHANGED
|
@@ -24,8 +24,9 @@ class PostgresPool extends DbPool {
|
|
|
24
24
|
}
|
|
25
25
|
const POOL_STATE = {};
|
|
26
26
|
const POOL_UNUSED = ['ssl', 'keepAlive', 'statement_timeout', 'query_timeout', 'keepAliveInitialDelayMillis', 'idle_in_transaction_session_timeout', 'connectionTimeoutMillis', 'max', 'min', 'idleTimeoutMillis', 'log', 'allowExitOnIdle', 'maxUses'];
|
|
27
|
+
const POOL_ACTIVE = new WeakSet();
|
|
27
28
|
function removePoolProperties(credential) {
|
|
28
|
-
if (!credential.uuidKey) {
|
|
29
|
+
if (!credential.uuidKey && POOL_ACTIVE.has(credential)) {
|
|
29
30
|
let result;
|
|
30
31
|
for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
|
|
31
32
|
const attr = POOL_UNUSED[i];
|
|
@@ -191,6 +192,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
191
192
|
if (postgresPool) {
|
|
192
193
|
pools.push(client = await postgresPool.getConnection());
|
|
193
194
|
item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
|
|
195
|
+
POOL_ACTIVE.add(credential);
|
|
194
196
|
return client;
|
|
195
197
|
}
|
|
196
198
|
const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
|
|
@@ -201,6 +203,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
201
203
|
postgresPool = pool;
|
|
202
204
|
}
|
|
203
205
|
pool.connected = true;
|
|
206
|
+
POOL_ACTIVE.add(credential);
|
|
204
207
|
}
|
|
205
208
|
catch (err) {
|
|
206
209
|
let close;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/postgres",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "PostgreSQL client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/db": "^0.8.
|
|
25
|
-
"@e-mc/types": "^0.8.
|
|
24
|
+
"@e-mc/db": "^0.8.4",
|
|
25
|
+
"@e-mc/types": "^0.8.4",
|
|
26
26
|
"pg": "^8.11.3",
|
|
27
27
|
"pg-connection-string": "^2.6.2",
|
|
28
28
|
"pg-query-stream": "^4.5.3"
|