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/dist/index.js
CHANGED
|
@@ -3208,6 +3208,13 @@ class Adapter {
|
|
|
3208
3208
|
constructor(_a) {
|
|
3209
3209
|
var _b = _a, { types: types2 = defaultTypeParsers } = _b, config = __objRest$1(_b, ["types"]);
|
|
3210
3210
|
this.types = types2;
|
|
3211
|
+
if (config.databaseURL) {
|
|
3212
|
+
config.connectionString = config.databaseURL;
|
|
3213
|
+
const url = new URL(config.databaseURL);
|
|
3214
|
+
if (url.searchParams.get("ssl") === "true") {
|
|
3215
|
+
config.ssl = true;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3211
3218
|
this.pool = new pg.Pool(config);
|
|
3212
3219
|
}
|
|
3213
3220
|
async query(query, types2) {
|
|
@@ -3393,16 +3400,21 @@ const then = async (q, resolve, reject) => {
|
|
|
3393
3400
|
}
|
|
3394
3401
|
resolve == null ? void 0 : resolve(result);
|
|
3395
3402
|
} catch (err) {
|
|
3396
|
-
|
|
3403
|
+
let error;
|
|
3404
|
+
if (err instanceof pg.DatabaseError) {
|
|
3405
|
+
error = new q.error();
|
|
3406
|
+
assignError(error, err);
|
|
3407
|
+
} else {
|
|
3408
|
+
error = err;
|
|
3409
|
+
}
|
|
3410
|
+
error.stack = queryError.stack;
|
|
3397
3411
|
if (q.query.log && sql && logData) {
|
|
3398
3412
|
q.query.log.onError(error, sql, logData);
|
|
3399
3413
|
}
|
|
3400
3414
|
reject == null ? void 0 : reject(error);
|
|
3401
3415
|
}
|
|
3402
3416
|
};
|
|
3403
|
-
const assignError = (
|
|
3404
|
-
const to = new q.error();
|
|
3405
|
-
to.stack = queryError.stack;
|
|
3417
|
+
const assignError = (to, from) => {
|
|
3406
3418
|
to.message = from.message;
|
|
3407
3419
|
to.length = from.length;
|
|
3408
3420
|
to.name = from.name;
|