pqb 0.7.7 → 0.7.9
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +16 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/adapter.ts +9 -1
- package/src/db.test.ts +13 -0
- package/src/queryMethods/then.test.ts +12 -0
- package/src/queryMethods/then.ts +10 -4
- package/src/test-utils/test-utils.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -180,8 +180,9 @@ declare type QueryArraysResult<R extends any[] = any[]> = {
|
|
|
180
180
|
name: string;
|
|
181
181
|
}[];
|
|
182
182
|
};
|
|
183
|
-
declare type AdapterOptions = Omit<PoolConfig, 'types'> & {
|
|
183
|
+
declare type AdapterOptions = Omit<PoolConfig, 'types' | 'connectionString'> & {
|
|
184
184
|
types?: TypeParsers;
|
|
185
|
+
databaseURL?: string;
|
|
185
186
|
};
|
|
186
187
|
declare class Adapter {
|
|
187
188
|
types: TypeParsers;
|
package/dist/index.esm.js
CHANGED
|
@@ -3204,6 +3204,13 @@ class Adapter {
|
|
|
3204
3204
|
constructor(_a) {
|
|
3205
3205
|
var _b = _a, { types: types2 = defaultTypeParsers } = _b, config = __objRest$1(_b, ["types"]);
|
|
3206
3206
|
this.types = types2;
|
|
3207
|
+
if (config.databaseURL) {
|
|
3208
|
+
config.connectionString = config.databaseURL;
|
|
3209
|
+
const url = new URL(config.databaseURL);
|
|
3210
|
+
if (url.searchParams.get("ssl") === "true") {
|
|
3211
|
+
config.ssl = true;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3207
3214
|
this.pool = new Pool(config);
|
|
3208
3215
|
}
|
|
3209
3216
|
async query(query, types2) {
|
|
@@ -3389,16 +3396,21 @@ const then = async (q, resolve, reject) => {
|
|
|
3389
3396
|
}
|
|
3390
3397
|
resolve == null ? void 0 : resolve(result);
|
|
3391
3398
|
} catch (err) {
|
|
3392
|
-
|
|
3399
|
+
let error;
|
|
3400
|
+
if (err instanceof DatabaseError) {
|
|
3401
|
+
error = new q.error();
|
|
3402
|
+
assignError(error, err);
|
|
3403
|
+
} else {
|
|
3404
|
+
error = err;
|
|
3405
|
+
}
|
|
3406
|
+
error.stack = queryError.stack;
|
|
3393
3407
|
if (q.query.log && sql && logData) {
|
|
3394
3408
|
q.query.log.onError(error, sql, logData);
|
|
3395
3409
|
}
|
|
3396
3410
|
reject == null ? void 0 : reject(error);
|
|
3397
3411
|
}
|
|
3398
3412
|
};
|
|
3399
|
-
const assignError = (
|
|
3400
|
-
const to = new q.error();
|
|
3401
|
-
to.stack = queryError.stack;
|
|
3413
|
+
const assignError = (to, from) => {
|
|
3402
3414
|
to.message = from.message;
|
|
3403
3415
|
to.length = from.length;
|
|
3404
3416
|
to.name = from.name;
|