pqb 0.39.2 → 0.39.3

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.js CHANGED
@@ -119,25 +119,25 @@ const sqlFn = (...args) => {
119
119
  return (...args2) => new RawSQL(args2, arg);
120
120
  };
121
121
 
122
- var __defProp$l = Object.defineProperty;
123
- var __defProps$b = Object.defineProperties;
124
- var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
125
- var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
126
- var __hasOwnProp$m = Object.prototype.hasOwnProperty;
127
- var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
128
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
129
- var __spreadValues$l = (a, b) => {
122
+ var __defProp$m = Object.defineProperty;
123
+ var __defProps$d = Object.defineProperties;
124
+ var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
125
+ var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
126
+ var __hasOwnProp$n = Object.prototype.hasOwnProperty;
127
+ var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
128
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
129
+ var __spreadValues$m = (a, b) => {
130
130
  for (var prop in b || (b = {}))
131
- if (__hasOwnProp$m.call(b, prop))
132
- __defNormalProp$l(a, prop, b[prop]);
133
- if (__getOwnPropSymbols$m)
134
- for (var prop of __getOwnPropSymbols$m(b)) {
135
- if (__propIsEnum$m.call(b, prop))
136
- __defNormalProp$l(a, prop, b[prop]);
131
+ if (__hasOwnProp$n.call(b, prop))
132
+ __defNormalProp$m(a, prop, b[prop]);
133
+ if (__getOwnPropSymbols$n)
134
+ for (var prop of __getOwnPropSymbols$n(b)) {
135
+ if (__propIsEnum$n.call(b, prop))
136
+ __defNormalProp$m(a, prop, b[prop]);
137
137
  }
138
138
  return a;
139
139
  };
140
- var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
140
+ var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
141
141
  class ColumnType extends orchidCore.ColumnTypeBase {
142
142
  /**
143
143
  * Mark the column as a primary key.
@@ -336,13 +336,13 @@ class ColumnType extends orchidCore.ColumnTypeBase {
336
336
  */
337
337
  searchIndex(...args) {
338
338
  return orchidCore.pushColumnData(this, "indexes", {
339
- options: __spreadValues$l(__spreadValues$l({}, typeof args[0] === "string" ? args[1] : args[0]), this.dataType === "tsvector" ? { using: "GIN" } : { tsVector: true }),
339
+ options: __spreadValues$m(__spreadValues$m({}, typeof args[0] === "string" ? args[1] : args[0]), this.dataType === "tsvector" ? { using: "GIN" } : { tsVector: true }),
340
340
  name: typeof args[0] === "string" ? args[0] : void 0
341
341
  });
342
342
  }
343
343
  unique(...args) {
344
344
  return orchidCore.pushColumnData(this, "indexes", {
345
- options: __spreadProps$b(__spreadValues$l({}, typeof args[0] === "string" ? args[1] : args[0]), {
345
+ options: __spreadProps$d(__spreadValues$m({}, typeof args[0] === "string" ? args[1] : args[0]), {
346
346
  unique: true
347
347
  }),
348
348
  name: typeof args[0] === "string" ? args[0] : void 0
@@ -385,25 +385,25 @@ class ColumnType extends orchidCore.ColumnTypeBase {
385
385
  }
386
386
  }
387
387
 
388
- var __defProp$k = Object.defineProperty;
389
- var __defProps$a = Object.defineProperties;
390
- var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
391
- var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
392
- var __hasOwnProp$l = Object.prototype.hasOwnProperty;
393
- var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
394
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
395
- var __spreadValues$k = (a, b) => {
388
+ var __defProp$l = Object.defineProperty;
389
+ var __defProps$c = Object.defineProperties;
390
+ var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
391
+ var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
392
+ var __hasOwnProp$m = Object.prototype.hasOwnProperty;
393
+ var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
394
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
395
+ var __spreadValues$l = (a, b) => {
396
396
  for (var prop in b || (b = {}))
397
- if (__hasOwnProp$l.call(b, prop))
398
- __defNormalProp$k(a, prop, b[prop]);
399
- if (__getOwnPropSymbols$l)
400
- for (var prop of __getOwnPropSymbols$l(b)) {
401
- if (__propIsEnum$l.call(b, prop))
402
- __defNormalProp$k(a, prop, b[prop]);
397
+ if (__hasOwnProp$m.call(b, prop))
398
+ __defNormalProp$l(a, prop, b[prop]);
399
+ if (__getOwnPropSymbols$m)
400
+ for (var prop of __getOwnPropSymbols$m(b)) {
401
+ if (__propIsEnum$m.call(b, prop))
402
+ __defNormalProp$l(a, prop, b[prop]);
403
403
  }
404
404
  return a;
405
405
  };
406
- var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
406
+ var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
407
407
  const knownDefaults = {
408
408
  current_timestamp: "now()",
409
409
  "transaction_timestamp()": "now()"
@@ -419,7 +419,7 @@ const simplifyColumnDefault = (value) => {
419
419
  const instantiateColumn = (typeFn, params) => {
420
420
  const column = typeFn();
421
421
  const { dateTimePrecision } = params;
422
- Object.assign(column.data, __spreadProps$a(__spreadValues$k({}, params), {
422
+ Object.assign(column.data, __spreadProps$c(__spreadValues$l({}, params), {
423
423
  dateTimePrecision: (
424
424
  // 0 is default for date, 6 is default for timestamp
425
425
  dateTimePrecision && dateTimePrecision !== 6 ? dateTimePrecision : void 0
@@ -858,25 +858,25 @@ const getSqlText = (sql) => {
858
858
  throw new Error(`Batch SQL is not supported in this query`);
859
859
  };
860
860
 
861
- var __defProp$j = Object.defineProperty;
862
- var __defProps$9 = Object.defineProperties;
863
- var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
864
- var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
865
- var __hasOwnProp$k = Object.prototype.hasOwnProperty;
866
- var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
867
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
868
- var __spreadValues$j = (a, b) => {
861
+ var __defProp$k = Object.defineProperty;
862
+ var __defProps$b = Object.defineProperties;
863
+ var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
864
+ var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
865
+ var __hasOwnProp$l = Object.prototype.hasOwnProperty;
866
+ var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
867
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
868
+ var __spreadValues$k = (a, b) => {
869
869
  for (var prop in b || (b = {}))
870
- if (__hasOwnProp$k.call(b, prop))
871
- __defNormalProp$j(a, prop, b[prop]);
872
- if (__getOwnPropSymbols$k)
873
- for (var prop of __getOwnPropSymbols$k(b)) {
874
- if (__propIsEnum$k.call(b, prop))
875
- __defNormalProp$j(a, prop, b[prop]);
870
+ if (__hasOwnProp$l.call(b, prop))
871
+ __defNormalProp$k(a, prop, b[prop]);
872
+ if (__getOwnPropSymbols$l)
873
+ for (var prop of __getOwnPropSymbols$l(b)) {
874
+ if (__propIsEnum$l.call(b, prop))
875
+ __defNormalProp$k(a, prop, b[prop]);
876
876
  }
877
877
  return a;
878
878
  };
879
- var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
879
+ var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
880
880
  function setQueryOperators(query, operators) {
881
881
  const q = query.q;
882
882
  if (q.operators !== operators) {
@@ -965,7 +965,7 @@ const base = {
965
965
  (key, value, ctx, quotedAs) => `NOT ${key} IN ${quoteValue$1(value, ctx, quotedAs)}`
966
966
  )
967
967
  };
968
- const boolean = __spreadProps$9(__spreadValues$j({}, base), {
968
+ const boolean = __spreadProps$b(__spreadValues$k({}, base), {
969
969
  and: make(
970
970
  (key, value, ctx, quotedAs) => `${key} AND ${value.q.expr.toSQL(ctx, quotedAs)}`
971
971
  ),
@@ -973,7 +973,7 @@ const boolean = __spreadProps$9(__spreadValues$j({}, base), {
973
973
  (key, value, ctx, quotedAs) => `(${key}) OR (${value.q.expr.toSQL(ctx, quotedAs)})`
974
974
  )
975
975
  });
976
- const numeric = __spreadProps$9(__spreadValues$j({}, base), {
976
+ const numeric = __spreadProps$b(__spreadValues$k({}, base), {
977
977
  lt: make(
978
978
  (key, value, ctx, quotedAs) => `${key} < ${quoteValue$1(value, ctx, quotedAs)}`
979
979
  ),
@@ -994,7 +994,7 @@ const numeric = __spreadProps$9(__spreadValues$j({}, base), {
994
994
  )}`
995
995
  )
996
996
  });
997
- const text = __spreadProps$9(__spreadValues$j({}, base), {
997
+ const text = __spreadProps$b(__spreadValues$k({}, base), {
998
998
  contains: make(
999
999
  (key, value, ctx, quotedAs) => `${key} ILIKE '%' || ${quoteLikeValue(value, ctx, quotedAs)} || '%'`
1000
1000
  ),
@@ -1016,7 +1016,7 @@ const text = __spreadProps$9(__spreadValues$j({}, base), {
1016
1016
  });
1017
1017
  const encodeJsonPath = (ctx, path) => orchidCore.addValue(ctx.values, `{${Array.isArray(path) ? path.join(", ") : path}}`);
1018
1018
  const jsonPathQueryOp = (key, [path, options], ctx) => `jsonb_path_query_first(${key}, ${orchidCore.addValue(ctx.values, path)}${(options == null ? void 0 : options.vars) ? `, ${orchidCore.addValue(ctx.values, JSON.stringify(options.vars))}${options.silent ? ", true" : ""}` : (options == null ? void 0 : options.silent) ? ", NULL, true" : ""})`;
1019
- const json = __spreadProps$9(__spreadValues$j({}, base), {
1019
+ const json = __spreadProps$b(__spreadValues$k({}, base), {
1020
1020
  jsonPathQueryFirst: Object.assign(
1021
1021
  function(path, options) {
1022
1022
  var _a, _b, _c, _d, _e;
@@ -1266,25 +1266,25 @@ class BigSerialColumn extends NumberAsStringBaseColumn {
1266
1266
  }
1267
1267
  }
1268
1268
 
1269
- var __defProp$i = Object.defineProperty;
1270
- var __defProps$8 = Object.defineProperties;
1271
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
1272
- var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
1273
- var __hasOwnProp$j = Object.prototype.hasOwnProperty;
1274
- var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
1275
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1276
- var __spreadValues$i = (a, b) => {
1269
+ var __defProp$j = Object.defineProperty;
1270
+ var __defProps$a = Object.defineProperties;
1271
+ var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
1272
+ var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
1273
+ var __hasOwnProp$k = Object.prototype.hasOwnProperty;
1274
+ var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
1275
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1276
+ var __spreadValues$j = (a, b) => {
1277
1277
  for (var prop in b || (b = {}))
1278
- if (__hasOwnProp$j.call(b, prop))
1279
- __defNormalProp$i(a, prop, b[prop]);
1280
- if (__getOwnPropSymbols$j)
1281
- for (var prop of __getOwnPropSymbols$j(b)) {
1282
- if (__propIsEnum$j.call(b, prop))
1283
- __defNormalProp$i(a, prop, b[prop]);
1278
+ if (__hasOwnProp$k.call(b, prop))
1279
+ __defNormalProp$j(a, prop, b[prop]);
1280
+ if (__getOwnPropSymbols$k)
1281
+ for (var prop of __getOwnPropSymbols$k(b)) {
1282
+ if (__propIsEnum$k.call(b, prop))
1283
+ __defNormalProp$j(a, prop, b[prop]);
1284
1284
  }
1285
1285
  return a;
1286
1286
  };
1287
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
1287
+ var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
1288
1288
  class TextBaseColumn extends ColumnType {
1289
1289
  constructor(schema, schemaType = schema.stringSchema()) {
1290
1290
  super(schema, schemaType);
@@ -1338,7 +1338,7 @@ class StringColumn extends VarCharColumn {
1338
1338
  }
1339
1339
  }
1340
1340
  const textColumnToCode = (column, ctx, key) => {
1341
- const data = __spreadValues$i({}, column.data);
1341
+ const data = __spreadValues$j({}, column.data);
1342
1342
  let args = "";
1343
1343
  const hasMax = data.maxArg !== void 0 && data.max === data.maxArg;
1344
1344
  if (data.minArg !== void 0 && data.min === data.minArg || hasMax) {
@@ -1642,7 +1642,7 @@ class UUIDColumn extends ColumnType {
1642
1642
  key,
1643
1643
  `uuid()`,
1644
1644
  // don't output the default default
1645
- data.default instanceof orchidCore.RawSQLBase && data.default._sql === uuidDefaultSQL ? __spreadProps$8(__spreadValues$i({}, data), { default: void 0 }) : data
1645
+ data.default instanceof orchidCore.RawSQLBase && data.default._sql === uuidDefaultSQL ? __spreadProps$a(__spreadValues$j({}, data), { default: void 0 }) : data
1646
1646
  );
1647
1647
  }
1648
1648
  }
@@ -2043,26 +2043,33 @@ var __privateSet = (obj, member, value, setter) => {
2043
2043
  setter ? setter.call(obj, value) : member.set(obj, value);
2044
2044
  return value;
2045
2045
  };
2046
- var _query;
2046
+ var _query, _query2;
2047
2047
  class OrchidOrmError extends Error {
2048
2048
  }
2049
2049
  class NotFoundError extends OrchidOrmError {
2050
2050
  constructor(query, message = "Record is not found") {
2051
2051
  super(message);
2052
- this.query = query;
2052
+ // `#query` is private to prevent it from serializing to not cause problems to test runner reports
2053
+ __privateAdd(this, _query, void 0);
2054
+ __privateSet(this, _query, query);
2055
+ }
2056
+ get query() {
2057
+ return __privateGet(this, _query);
2053
2058
  }
2054
2059
  }
2060
+ _query = new WeakMap();
2055
2061
  class OrchidOrmInternalError extends Error {
2056
2062
  constructor(query, message) {
2057
2063
  super(message);
2058
- __privateAdd(this, _query, void 0);
2059
- __privateSet(this, _query, query);
2064
+ // `#query` is private to prevent it from serializing to not cause problems to test runner reports
2065
+ __privateAdd(this, _query2, void 0);
2066
+ __privateSet(this, _query2, query);
2060
2067
  }
2061
2068
  get query() {
2062
- return __privateGet(this, _query);
2069
+ return __privateGet(this, _query2);
2063
2070
  }
2064
2071
  }
2065
- _query = new WeakMap();
2072
+ _query2 = new WeakMap();
2066
2073
  class QueryError extends OrchidOrmInternalError {
2067
2074
  get isUnique() {
2068
2075
  return this.code === "23505";
@@ -2418,25 +2425,25 @@ const pushIn = (ctx, query, ands, quotedAs, arg) => {
2418
2425
  ands.push(`${multiple ? `(${columnsSql})` : columnsSql} IN ${value}`);
2419
2426
  };
2420
2427
 
2421
- var __defProp$h = Object.defineProperty;
2422
- var __defProps$7 = Object.defineProperties;
2423
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
2424
- var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
2425
- var __hasOwnProp$i = Object.prototype.hasOwnProperty;
2426
- var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
2427
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2428
- var __spreadValues$h = (a, b) => {
2428
+ var __defProp$i = Object.defineProperty;
2429
+ var __defProps$9 = Object.defineProperties;
2430
+ var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
2431
+ var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
2432
+ var __hasOwnProp$j = Object.prototype.hasOwnProperty;
2433
+ var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
2434
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2435
+ var __spreadValues$i = (a, b) => {
2429
2436
  for (var prop in b || (b = {}))
2430
- if (__hasOwnProp$i.call(b, prop))
2431
- __defNormalProp$h(a, prop, b[prop]);
2432
- if (__getOwnPropSymbols$i)
2433
- for (var prop of __getOwnPropSymbols$i(b)) {
2434
- if (__propIsEnum$i.call(b, prop))
2435
- __defNormalProp$h(a, prop, b[prop]);
2437
+ if (__hasOwnProp$j.call(b, prop))
2438
+ __defNormalProp$i(a, prop, b[prop]);
2439
+ if (__getOwnPropSymbols$j)
2440
+ for (var prop of __getOwnPropSymbols$j(b)) {
2441
+ if (__propIsEnum$j.call(b, prop))
2442
+ __defNormalProp$i(a, prop, b[prop]);
2436
2443
  }
2437
2444
  return a;
2438
2445
  };
2439
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
2446
+ var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
2440
2447
  const processJoinItem = (ctx, table, query, args, quotedAs) => {
2441
2448
  let target;
2442
2449
  let on;
@@ -2498,8 +2505,8 @@ const processJoinItem = (ctx, table, query, args, quotedAs) => {
2498
2505
  const whereSql = whereToSql(
2499
2506
  ctx,
2500
2507
  q,
2501
- __spreadProps$7(__spreadValues$h({}, q.q), {
2502
- joinedShapes: __spreadProps$7(__spreadValues$h(__spreadValues$h({}, query.joinedShapes), q.q.joinedShapes), {
2508
+ __spreadProps$9(__spreadValues$i({}, q.q), {
2509
+ joinedShapes: __spreadProps$9(__spreadValues$i(__spreadValues$i({}, query.joinedShapes), q.q.joinedShapes), {
2503
2510
  [table.q.as || table.table]: table.q.shape
2504
2511
  })
2505
2512
  }),
@@ -2646,25 +2653,25 @@ const getIsJoinSubQuery = (query) => {
2646
2653
  return false;
2647
2654
  };
2648
2655
 
2649
- var __defProp$g = Object.defineProperty;
2650
- var __defProps$6 = Object.defineProperties;
2651
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
2652
- var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
2653
- var __hasOwnProp$h = Object.prototype.hasOwnProperty;
2654
- var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
2655
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2656
- var __spreadValues$g = (a, b) => {
2656
+ var __defProp$h = Object.defineProperty;
2657
+ var __defProps$8 = Object.defineProperties;
2658
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
2659
+ var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
2660
+ var __hasOwnProp$i = Object.prototype.hasOwnProperty;
2661
+ var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
2662
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2663
+ var __spreadValues$h = (a, b) => {
2657
2664
  for (var prop in b || (b = {}))
2658
- if (__hasOwnProp$h.call(b, prop))
2659
- __defNormalProp$g(a, prop, b[prop]);
2660
- if (__getOwnPropSymbols$h)
2661
- for (var prop of __getOwnPropSymbols$h(b)) {
2662
- if (__propIsEnum$h.call(b, prop))
2663
- __defNormalProp$g(a, prop, b[prop]);
2665
+ if (__hasOwnProp$i.call(b, prop))
2666
+ __defNormalProp$h(a, prop, b[prop]);
2667
+ if (__getOwnPropSymbols$i)
2668
+ for (var prop of __getOwnPropSymbols$i(b)) {
2669
+ if (__propIsEnum$i.call(b, prop))
2670
+ __defNormalProp$h(a, prop, b[prop]);
2664
2671
  }
2665
2672
  return a;
2666
2673
  };
2667
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
2674
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
2668
2675
  const processJoinArgs = (joinTo, first, args, joinSubQuery, whereExists) => {
2669
2676
  var _a;
2670
2677
  if (typeof first === "string") {
@@ -2701,13 +2708,13 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery, whereExists) => {
2701
2708
  logger: joinToQ.logger
2702
2709
  };
2703
2710
  j.baseQuery = j;
2704
- const joinedShapes = __spreadProps$6(__spreadValues$g({}, joinToQ.joinedShapes), {
2711
+ const joinedShapes = __spreadProps$8(__spreadValues$h({}, joinToQ.joinedShapes), {
2705
2712
  [joinToQ.as || joinTo.table]: joinTo.shape
2706
2713
  });
2707
2714
  const r = args[0](
2708
2715
  makeJoinQueryBuilder(
2709
2716
  j,
2710
- j.q.joinedShapes ? __spreadValues$g(__spreadValues$g({}, j.q.joinedShapes), joinedShapes) : joinedShapes,
2717
+ j.q.joinedShapes ? __spreadValues$h(__spreadValues$h({}, j.q.joinedShapes), joinedShapes) : joinedShapes,
2711
2718
  joinTo
2712
2719
  )
2713
2720
  );
@@ -2734,16 +2741,16 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery, whereExists) => {
2734
2741
  pushQueryArray(q, "or", query.or);
2735
2742
  }
2736
2743
  if (query.scopes) {
2737
- q.q.scopes = __spreadValues$g(__spreadValues$g({}, q.q.scopes), query.scopes);
2744
+ q.q.scopes = __spreadValues$h(__spreadValues$h({}, q.q.scopes), query.scopes);
2738
2745
  }
2739
2746
  }
2740
- const joinedShapes = __spreadProps$6(__spreadValues$g({}, joinTo.q.joinedShapes), {
2747
+ const joinedShapes = __spreadProps$8(__spreadValues$h({}, joinTo.q.joinedShapes), {
2741
2748
  [joinTo.q.as || joinTo.table]: joinTo.shape
2742
2749
  });
2743
2750
  const r = args0(
2744
2751
  makeJoinQueryBuilder(
2745
2752
  q,
2746
- q.q.joinedShapes ? __spreadValues$g(__spreadValues$g({}, q.q.joinedShapes), joinedShapes) : joinedShapes,
2753
+ q.q.joinedShapes ? __spreadValues$h(__spreadValues$h({}, q.q.joinedShapes), joinedShapes) : joinedShapes,
2747
2754
  joinTo
2748
2755
  )
2749
2756
  );
@@ -2791,25 +2798,25 @@ const _queryNone = (q) => {
2791
2798
  };
2792
2799
  const isQueryNone = (q) => q.then === noneMethods.then;
2793
2800
 
2794
- var __defProp$f = Object.defineProperty;
2795
- var __defProps$5 = Object.defineProperties;
2796
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
2797
- var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
2798
- var __hasOwnProp$g = Object.prototype.hasOwnProperty;
2799
- var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
2800
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2801
- var __spreadValues$f = (a, b) => {
2801
+ var __defProp$g = Object.defineProperty;
2802
+ var __defProps$7 = Object.defineProperties;
2803
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
2804
+ var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
2805
+ var __hasOwnProp$h = Object.prototype.hasOwnProperty;
2806
+ var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
2807
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2808
+ var __spreadValues$g = (a, b) => {
2802
2809
  for (var prop in b || (b = {}))
2803
- if (__hasOwnProp$g.call(b, prop))
2804
- __defNormalProp$f(a, prop, b[prop]);
2805
- if (__getOwnPropSymbols$g)
2806
- for (var prop of __getOwnPropSymbols$g(b)) {
2807
- if (__propIsEnum$g.call(b, prop))
2808
- __defNormalProp$f(a, prop, b[prop]);
2810
+ if (__hasOwnProp$h.call(b, prop))
2811
+ __defNormalProp$g(a, prop, b[prop]);
2812
+ if (__getOwnPropSymbols$h)
2813
+ for (var prop of __getOwnPropSymbols$h(b)) {
2814
+ if (__propIsEnum$h.call(b, prop))
2815
+ __defNormalProp$g(a, prop, b[prop]);
2809
2816
  }
2810
2817
  return a;
2811
2818
  };
2812
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
2819
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
2813
2820
  const _join = (query, require2, type, first, args) => {
2814
2821
  var _a, _b, _c, _d;
2815
2822
  let joinKey;
@@ -2854,7 +2861,7 @@ const _join = (query, require2, type, first, args) => {
2854
2861
  computeds = w == null ? void 0 : w.computeds;
2855
2862
  if (shape) {
2856
2863
  if (!require2)
2857
- shape = __spreadValues$f({}, shape);
2864
+ shape = __spreadValues$g({}, shape);
2858
2865
  parsers = {};
2859
2866
  for (const key in shape) {
2860
2867
  const parser = shape[key].parseFn;
@@ -2954,7 +2961,7 @@ const _joinLateral = (self, type, arg, cb, as) => {
2954
2961
  t.table = arg;
2955
2962
  t.shape = w.shape;
2956
2963
  t.computeds = w.computeds;
2957
- t.q = __spreadProps$5(__spreadValues$f({}, t.q), {
2964
+ t.q = __spreadProps$7(__spreadValues$g({}, t.q), {
2958
2965
  shape: w.shape
2959
2966
  });
2960
2967
  t.baseQuery = t;
@@ -3273,12 +3280,46 @@ class QueryLog {
3273
3280
  }
3274
3281
  }
3275
3282
 
3283
+ var __defProp$f = Object.defineProperty;
3284
+ var __defProps$6 = Object.defineProperties;
3285
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
3286
+ var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
3287
+ var __hasOwnProp$g = Object.prototype.hasOwnProperty;
3288
+ var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
3289
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3290
+ var __spreadValues$f = (a, b) => {
3291
+ for (var prop in b || (b = {}))
3292
+ if (__hasOwnProp$g.call(b, prop))
3293
+ __defNormalProp$f(a, prop, b[prop]);
3294
+ if (__getOwnPropSymbols$g)
3295
+ for (var prop of __getOwnPropSymbols$g(b)) {
3296
+ if (__propIsEnum$g.call(b, prop))
3297
+ __defNormalProp$f(a, prop, b[prop]);
3298
+ }
3299
+ return a;
3300
+ };
3301
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
3276
3302
  const commitSql$1 = {
3277
3303
  text: "COMMIT"
3278
3304
  };
3279
3305
  const rollbackSql$1 = {
3280
3306
  text: "ROLLBACK"
3281
3307
  };
3308
+ class AfterCommitError extends OrchidOrmError {
3309
+ constructor(result, hookResults) {
3310
+ super("After commit hooks have failed");
3311
+ this.result = result;
3312
+ this.hookResults = hookResults;
3313
+ }
3314
+ }
3315
+ const _afterCommitError = (result, hookResults, catchAfterCommitError) => {
3316
+ const err = new AfterCommitError(result, hookResults);
3317
+ if (catchAfterCommitError) {
3318
+ catchAfterCommitError(err);
3319
+ } else {
3320
+ throw err;
3321
+ }
3322
+ };
3282
3323
  class Transaction {
3283
3324
  async transaction(cbOrOptions, cb) {
3284
3325
  var _a;
@@ -3324,7 +3365,10 @@ class Transaction {
3324
3365
  const result = await this.q.adapter.transaction(sql, callback);
3325
3366
  if (log)
3326
3367
  log.afterQuery(commitSql$1, logData);
3327
- await runAfterCommit(trx.afterCommit);
3368
+ await runAfterCommit(
3369
+ trx.afterCommit,
3370
+ result
3371
+ );
3328
3372
  return result;
3329
3373
  } catch (err) {
3330
3374
  if (log)
@@ -3358,7 +3402,8 @@ class Transaction {
3358
3402
  log.afterQuery(sql, logData);
3359
3403
  if (transactionId === trx.testTransactionCount) {
3360
3404
  await runAfterCommit(
3361
- trx.afterCommit
3405
+ trx.afterCommit,
3406
+ result
3362
3407
  );
3363
3408
  }
3364
3409
  return result;
@@ -3368,17 +3413,37 @@ class Transaction {
3368
3413
  }
3369
3414
  }
3370
3415
  }
3371
- const runAfterCommit = async (afterCommit) => {
3416
+ const runAfterCommit = async (afterCommit, result) => {
3372
3417
  if (afterCommit) {
3373
3418
  const promises = [];
3419
+ let catchAfterCommitError;
3374
3420
  for (let i = 0, len = afterCommit.length; i < len; i += 3) {
3375
- const result = afterCommit[i];
3421
+ const result2 = afterCommit[i];
3376
3422
  const q = afterCommit[i + 1];
3423
+ if (q.q.catchAfterCommitError) {
3424
+ catchAfterCommitError = q.q.catchAfterCommitError;
3425
+ }
3377
3426
  for (const fn of afterCommit[i + 2]) {
3378
- promises.push(fn(result, q));
3427
+ try {
3428
+ promises.push(fn(result2, q));
3429
+ } catch (err) {
3430
+ promises.push(Promise.reject(err));
3431
+ }
3432
+ }
3433
+ }
3434
+ const hookResults = await Promise.allSettled(promises);
3435
+ if (hookResults.some((result2) => result2.status === "rejected")) {
3436
+ const resultsWithNames = [];
3437
+ let r = 0;
3438
+ for (let i = 0, len = afterCommit.length; i < len; i += 3) {
3439
+ for (const fn of afterCommit[i + 2]) {
3440
+ resultsWithNames.push(__spreadProps$6(__spreadValues$f({}, hookResults[r++]), {
3441
+ name: fn.name
3442
+ }));
3443
+ }
3379
3444
  }
3445
+ _afterCommitError(result, resultsWithNames, catchAfterCommitError);
3380
3446
  }
3381
- await Promise.all(promises);
3382
3447
  }
3383
3448
  };
3384
3449
 
@@ -3435,8 +3500,8 @@ const finalizeNestedHookSelect = (batches, returnType, tempColumns, renames, key
3435
3500
  };
3436
3501
 
3437
3502
  var __defProp$e = Object.defineProperty;
3438
- var __defProps$4 = Object.defineProperties;
3439
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
3503
+ var __defProps$5 = Object.defineProperties;
3504
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
3440
3505
  var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
3441
3506
  var __hasOwnProp$f = Object.prototype.hasOwnProperty;
3442
3507
  var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
@@ -3452,7 +3517,7 @@ var __spreadValues$e = (a, b) => {
3452
3517
  }
3453
3518
  return a;
3454
3519
  };
3455
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
3520
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
3456
3521
  class ComputedColumn {
3457
3522
  constructor(kind, deps, fn) {
3458
3523
  this.kind = kind;
@@ -3469,7 +3534,7 @@ const applyComputedColumns = (q, fn) => {
3469
3534
  for (const key in computed) {
3470
3535
  const item = computed[key];
3471
3536
  if (item instanceof ComputedColumn) {
3472
- q.q.computeds = __spreadProps$4(__spreadValues$e({}, q.q.computeds), { [key]: item });
3537
+ q.q.computeds = __spreadProps$5(__spreadValues$e({}, q.q.computeds), { [key]: item });
3473
3538
  } else {
3474
3539
  (q.shape[key] = item.result.value || UnknownColumn.instance).data.computed = item;
3475
3540
  }
@@ -3578,6 +3643,8 @@ const saveBatchComputed = (key, result, res, blanks) => {
3578
3643
  };
3579
3644
 
3580
3645
  var __defProp$d = Object.defineProperty;
3646
+ var __defProps$4 = Object.defineProperties;
3647
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
3581
3648
  var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
3582
3649
  var __hasOwnProp$e = Object.prototype.hasOwnProperty;
3583
3650
  var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
@@ -3593,6 +3660,7 @@ var __spreadValues$d = (a, b) => {
3593
3660
  }
3594
3661
  return a;
3595
3662
  };
3663
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
3596
3664
  const queryMethodByReturnType = {
3597
3665
  undefined: "query",
3598
3666
  all: "query",
@@ -3813,15 +3881,35 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
3813
3881
  )
3814
3882
  );
3815
3883
  }
3816
- if (afterCommitHooks && trx) {
3817
- ((_c = trx.afterCommit) != null ? _c : trx.afterCommit = []).push(
3818
- result,
3819
- q,
3820
- afterCommitHooks
3821
- );
3822
- } else if (afterCommitHooks) {
3823
- const args = [result, q];
3824
- await Promise.all(afterCommitHooks.map(callAfterHook, args));
3884
+ if (afterCommitHooks) {
3885
+ if (trx) {
3886
+ ((_c = trx.afterCommit) != null ? _c : trx.afterCommit = []).push(
3887
+ result,
3888
+ q,
3889
+ afterCommitHooks
3890
+ );
3891
+ } else {
3892
+ const promises = [];
3893
+ for (const fn of afterCommitHooks) {
3894
+ try {
3895
+ promises.push(
3896
+ fn(result, q)
3897
+ );
3898
+ } catch (err) {
3899
+ promises.push(Promise.reject(err));
3900
+ }
3901
+ }
3902
+ const hookResults = await Promise.allSettled(promises);
3903
+ if (hookResults.some((result2) => result2.status === "rejected")) {
3904
+ _afterCommitError(
3905
+ result,
3906
+ hookResults.map((result2, i) => __spreadProps$4(__spreadValues$d({}, result2), {
3907
+ name: afterCommitHooks[i].name
3908
+ })),
3909
+ q.q.catchAfterCommitError
3910
+ );
3911
+ }
3912
+ }
3825
3913
  }
3826
3914
  } else if (query.after) {
3827
3915
  const args = [result, q];
@@ -8437,6 +8525,32 @@ class QueryHooks {
8437
8525
  cb
8438
8526
  );
8439
8527
  }
8528
+ /**
8529
+ * Add `catchAfterCommitError` to the query to catch possible errors that are coming from after commit hooks.
8530
+ *
8531
+ * When it is used, the transaction will return its result disregarding of a failed hook.
8532
+ *
8533
+ * Without `catchAfterCommitError`, the transaction function throws and won't return result.
8534
+ * Result is still accessible from the error object [AfterCommitError](#AfterCommitError).
8535
+ *
8536
+ * ```ts
8537
+ * const result = await db
8538
+ * .$transaction(async () => {
8539
+ * return db.table.create(data);
8540
+ * })
8541
+ * .catchAfterCommitError((err) => {
8542
+ * // err is instance of AfterCommitError (see below)
8543
+ * });
8544
+ *
8545
+ * // result is available even if an after commit hook has failed
8546
+ * result.id;
8547
+ * ```
8548
+ */
8549
+ catchAfterCommitError(fn) {
8550
+ const q = this.clone();
8551
+ q.q.catchAfterCommitError = fn;
8552
+ return q;
8553
+ }
8440
8554
  }
8441
8555
 
8442
8556
  class Join {
@@ -12892,6 +13006,7 @@ function copyTableData(query, arg) {
12892
13006
  }
12893
13007
 
12894
13008
  exports.Adapter = Adapter;
13009
+ exports.AfterCommitError = AfterCommitError;
12895
13010
  exports.AggregateMethods = AggregateMethods;
12896
13011
  exports.ArrayColumn = ArrayColumn;
12897
13012
  exports.AsMethods = AsMethods;
@@ -12993,6 +13108,7 @@ exports.VirtualColumn = VirtualColumn;
12993
13108
  exports.Where = Where;
12994
13109
  exports.WithMethods = WithMethods;
12995
13110
  exports.XMLColumn = XMLColumn;
13111
+ exports._afterCommitError = _afterCommitError;
12996
13112
  exports._getSelectableColumn = _getSelectableColumn;
12997
13113
  exports._initQueryBuilder = _initQueryBuilder;
12998
13114
  exports._queryAfterSaveCommit = _queryAfterSaveCommit;