pqb 0.5.9 → 0.6.0

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.esm.js CHANGED
@@ -3162,21 +3162,11 @@ class Adapter {
3162
3162
  this.types = types2;
3163
3163
  this.pool = new Pool(config);
3164
3164
  }
3165
- async query(query, types2 = this.types) {
3166
- const client = await this.pool.connect();
3167
- try {
3168
- return await performQuery(client, query, types2);
3169
- } finally {
3170
- client.release();
3171
- }
3165
+ async query(query, types2) {
3166
+ return performQuery(this.pool, query, types2);
3172
3167
  }
3173
- async arrays(query, types2 = this.types) {
3174
- const client = await this.pool.connect();
3175
- try {
3176
- return await performQueryArrays(client, query, types2);
3177
- } finally {
3178
- client.release();
3179
- }
3168
+ async arrays(query, types2) {
3169
+ return performQueryArrays(this.pool, query, types2);
3180
3170
  }
3181
3171
  async transaction(cb) {
3182
3172
  const client = await this.pool.connect();
@@ -3198,27 +3188,32 @@ class Adapter {
3198
3188
  return this.pool.end();
3199
3189
  }
3200
3190
  }
3201
- const performQuery = (client, query, types2) => {
3202
- return client.query({
3191
+ const defaultTypesConfig = {
3192
+ getTypeParser(id) {
3193
+ return defaultTypeParsers[id] || returnArg;
3194
+ }
3195
+ };
3196
+ const performQuery = (pool, query, types2) => {
3197
+ return pool.query({
3203
3198
  text: typeof query === "string" ? query : query.text,
3204
3199
  values: typeof query === "string" ? void 0 : query.values,
3205
- types: types2 && {
3200
+ types: types2 ? {
3206
3201
  getTypeParser(id) {
3207
3202
  return types2[id] || returnArg;
3208
3203
  }
3209
- }
3204
+ } : defaultTypesConfig
3210
3205
  });
3211
3206
  };
3212
- const performQueryArrays = (client, query, types2) => {
3213
- return client.query({
3207
+ const performQueryArrays = (pool, query, types2) => {
3208
+ return pool.query({
3214
3209
  text: typeof query === "string" ? query : query.text,
3215
3210
  values: typeof query === "string" ? void 0 : query.values,
3216
3211
  rowMode: "array",
3217
- types: types2 && {
3212
+ types: types2 ? {
3218
3213
  getTypeParser(id) {
3219
3214
  return types2[id] || returnArg;
3220
3215
  }
3221
- }
3216
+ } : defaultTypesConfig
3222
3217
  });
3223
3218
  };
3224
3219
  class TransactionAdapter {
@@ -3227,10 +3222,10 @@ class TransactionAdapter {
3227
3222
  this.client = client;
3228
3223
  this.types = types2;
3229
3224
  }
3230
- async query(query, types2 = this.types) {
3225
+ async query(query, types2) {
3231
3226
  return await performQuery(this.client, query, types2);
3232
3227
  }
3233
- async arrays(query, types2 = this.types) {
3228
+ async arrays(query, types2) {
3234
3229
  return await performQueryArrays(this.client, query, types2);
3235
3230
  }
3236
3231
  async transaction(cb) {