pqb 0.3.9 → 0.4.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.d.ts CHANGED
@@ -818,6 +818,50 @@ declare class OnQueryBuilder<S extends QueryBase = QueryBase, J extends QueryBas
818
818
  _onJsonPathEquals<T extends this>(this: T, ...args: OnJsonPathEqualsArgs<T>): T;
819
819
  }
820
820
 
821
+ declare class PormError extends Error {
822
+ }
823
+ declare type QueryErrorName = 'parseComplete' | 'bindComplete' | 'closeComplete' | 'noData' | 'portalSuspended' | 'replicationStart' | 'emptyQuery' | 'copyDone' | 'copyData' | 'rowDescription' | 'parameterDescription' | 'parameterStatus' | 'backendKeyData' | 'notification' | 'readyForQuery' | 'commandComplete' | 'dataRow' | 'copyInResponse' | 'copyOutResponse' | 'authenticationOk' | 'authenticationMD5Password' | 'authenticationCleartextPassword' | 'authenticationSASL' | 'authenticationSASLContinue' | 'authenticationSASLFinal' | 'error' | 'notice';
824
+ declare class QueryError<T extends {
825
+ shape: ColumnsShape;
826
+ } = {
827
+ shape: ColumnsShape;
828
+ }> extends DatabaseError {
829
+ message: string;
830
+ name: QueryErrorName;
831
+ stack: string | undefined;
832
+ code: string | undefined;
833
+ detail: string | undefined;
834
+ severity: string | undefined;
835
+ hint: string | undefined;
836
+ position: string | undefined;
837
+ internalPosition: string | undefined;
838
+ internalQuery: string | undefined;
839
+ where: string | undefined;
840
+ schema: string | undefined;
841
+ table: string | undefined;
842
+ column: string | undefined;
843
+ dataType: string | undefined;
844
+ constraint: string | undefined;
845
+ file: string | undefined;
846
+ line: string | undefined;
847
+ routine: string | undefined;
848
+ get isUnique(): boolean;
849
+ columnsCache?: {
850
+ [K in keyof T['shape']]?: true;
851
+ };
852
+ get columns(): T["shape"] extends infer T_1 ? { [K in keyof T_1]?: true | undefined; } : never;
853
+ }
854
+ declare class NotFoundError extends PormError {
855
+ constructor(message?: string);
856
+ }
857
+ declare class MoreThanOneRowError extends PormError {
858
+ }
859
+ declare class PormInternalError extends Error {
860
+ }
861
+ declare class UnhandledTypeError extends PormInternalError {
862
+ constructor(value: never);
863
+ }
864
+
821
865
  declare type DbTableOptions = {
822
866
  schema?: string;
823
867
  } & QueryLogOptions;
@@ -858,6 +902,7 @@ interface Db<Table extends string | undefined = undefined, Shape extends Columns
858
902
  columnsParsers?: ColumnsParsers;
859
903
  relations: Relations;
860
904
  withData: Query['withData'];
905
+ error: new (message: string, length: number, name: QueryErrorName) => QueryError<this>;
861
906
  [defaultsKey]: Record<{
862
907
  [K in keyof Shape]: Shape[K]['hasDefault'] extends true ? K : never;
863
908
  }[keyof Shape], true>;
@@ -1496,6 +1541,7 @@ declare type Query = QueryMethods & {
1496
1541
  columnsParsers?: ColumnsParsers;
1497
1542
  relations: RelationsBase;
1498
1543
  withData: WithDataBase;
1544
+ error: new (message: string, length: number, name: QueryErrorName) => QueryError;
1499
1545
  [defaultsKey]: {};
1500
1546
  };
1501
1547
  declare type Selectable<T extends QueryBase> = StringKey<keyof T['selectable']>;
@@ -4037,9 +4083,9 @@ declare const jsonTypes: {
4037
4083
  nativeEnum: <T_6 extends EnumLike>(givenEnum: T_6) => JSONNativeEnum<T_6>;
4038
4084
  nullable: <T_7 extends JSONTypeAny>(type: T_7) => JSONNullable<T_7>;
4039
4085
  nullish: <T_8 extends JSONTypeAny>(type: T_8) => JSONNullish<T_8>;
4040
- object: <T_9 extends JSONObjectShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends JSONTypeAny = JSONTypeAny>(shape: T_9) => JSONObject<T_9, UnknownKeys, Catchall, JSONTypeAny extends Catchall ? addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 extends object ? { [k in keyof T_10]: addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never : (addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 extends object ? { [k in keyof T_10]: addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never) & {
4086
+ object: <T_9 extends JSONObjectShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends JSONTypeAny = JSONTypeAny>(shape: T_9) => JSONObject<T_9, UnknownKeys, Catchall, JSONTypeAny extends Catchall ? addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 ? { [k in keyof T_10]: addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never : (addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 ? { [k in keyof T_10]: addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never) & {
4041
4087
  [k: string]: Catchall["type"];
4042
- } extends infer T_11 extends object ? { [k_2 in keyof T_11]: ((addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 extends object ? { [k in keyof T_10]: addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never) & {
4088
+ } extends infer T_11 ? { [k_2 in keyof T_11]: ((addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }> extends infer T_10 ? { [k in keyof T_10]: addQuestionMarks<{ [k_1 in keyof T_9]: T_9[k_1]["type"]; }>[k]; } : never) & {
4043
4089
  [k: string]: Catchall["type"];
4044
4090
  })[k_2]; } : never>;
4045
4091
  optional: <T_12 extends JSONTypeAny>(type: T_12) => JSONOptional<T_12>;
@@ -4259,39 +4305,4 @@ declare const setQueryObjectValue: <T extends {
4259
4305
  query: QueryData;
4260
4306
  }>(q: T, object: string, key: string, value: unknown) => T;
4261
4307
 
4262
- declare class PormError extends Error {
4263
- }
4264
- declare class QueryError extends DatabaseError {
4265
- message: string;
4266
- code: string | undefined;
4267
- detail: string | undefined;
4268
- severity: string | undefined;
4269
- hint: string | undefined;
4270
- position: string | undefined;
4271
- internalPosition: string | undefined;
4272
- internalQuery: string | undefined;
4273
- where: string | undefined;
4274
- schema: string | undefined;
4275
- table: string | undefined;
4276
- column: string | undefined;
4277
- dataType: string | undefined;
4278
- constraint: string | undefined;
4279
- file: string | undefined;
4280
- line: string | undefined;
4281
- routine: string | undefined;
4282
- get isUnique(): boolean;
4283
- columnsCache?: Record<string, boolean>;
4284
- get columns(): Record<string, boolean>;
4285
- }
4286
- declare class NotFoundError extends PormError {
4287
- constructor(message?: string);
4288
- }
4289
- declare class MoreThanOneRowError extends PormError {
4290
- }
4291
- declare class PormInternalError extends Error {
4292
- }
4293
- declare class UnhandledTypeError extends PormInternalError {
4294
- constructor(value: never);
4295
- }
4296
-
4297
- export { Adapter, AdapterOptions, AddQueryJoinedTable, AddQuerySelect, AddQueryWith, AfterCallback, Aggregate, Aggregate1ArgumentTypes, AggregateArg, AggregateItem, AggregateItemArg, AggregateItemOptions, AggregateOptions, AliasOrTable, AnyColumnType, AnyColumnTypeCreator, ArrayCardinality, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AssertArray, BaseNumberData, BaseRelation, BaseStringData, BeforeCallback, BelongsToNestedInsert, BelongsToNestedUpdate, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanExpression, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ClearStatement, CoalesceString, ColumnData, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnInput, ColumnNameOfModel, ColumnOperators, ColumnOutput, ColumnParser, ColumnShapeInput, ColumnShapeOutput, ColumnType, ColumnTypes, ColumnTypesBase, ColumnsObject, ColumnsParsers, ColumnsShape, CommonQueryData, DateBaseColumn, DateColumn, DateColumnData, DateTimeBaseClass, DateTimeColumnData, DateTimeWithTimeZoneBaseClass, Db, DbOptions, DbTableOptions, DecimalBaseColumn, DecimalColumn, DecimalColumnData, DeepPartial, DefaultSelectColumns, Delete, DeleteQueryData, DoublePrecisionColumn, DropMode, EMPTY_OBJECT, EmptyObject, EnumColumn, EnumLike, Except, Expression, ExpressionOfType, ExpressionOutput, FilterTuple, For, ForeignKey, ForeignKeyModel, ForeignKeyModelWithColumns, ForeignKeyOptions, From, GetArg, HasAndBelongsToManyRelation, HasManyNestedInsert, HasManyNestedUpdate, HasManyRelation, HasOneNestedInsert, HasOneNestedUpdate, HasOneRelation, Having, HavingArg, HavingItem, IndexColumnOptions, IndexOptions, InetColumn, Insert, InsertData, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsEqual, JSONAny, JSONArray, JSONBigInt, JSONBoolean, JSONColumn, JSONDate, JSONDiscriminatedObject, JSONDiscriminatedUnion, JSONEnum, JSONInstanceOf, JSONIntersection, JSONLazy, JSONLiteral, JSONMap, JSONNaN, JSONNativeEnum, JSONNever, JSONNotNullable, JSONNotNullish, JSONNull, JSONNullable, JSONNullish, JSONNumber, JSONObject, JSONObjectShape, JSONOptional, JSONRecord, JSONRecordKeyType, JSONRequired, JSONSet, JSONString, JSONTextColumn, JSONTuple, JSONTupleItems, JSONType, JSONTypeAny, JSONTypeData, JSONTypes, JSONUndefined, JSONUnion, JSONUnknown, JSONVoid, Join, JoinArgs, JoinCallback, JoinCallbackArg, JoinItem, JoinedTablesBase, Json, JsonItem, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MaybeArray, Merge, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NestedInsertItem, NestedInsertManyItems, NestedInsertOneItem, NestedUpdateItem, NestedUpdateManyItems, NestedUpdateOneItem, NotFoundError, NullableColumn, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, NumberExpression, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrderArg, OrderItem, OutputTypeOfTuple, OutputTypeOfTupleWithRest, OwnTypeProps, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, Primitive, Query, QueryArraysResult, QueryBase, QueryCallbacks, QueryData, QueryError, QueryGet, QueryInput, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryResultRow, QueryReturnType, QueryReturnsAll, QuerySelectAll, QueryThen, QueryUpsert, QueryWithTable, RawExpression, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationsBase, Select, SelectAgg, SelectArg, SelectFunctionItem, SelectItem, SelectQueryData, Selectable, SelectableBase, SerialColumn, SetOptional, SetQueryJoinedTables, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumnInfo, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWindows, SetQueryWith, SimpleSpread, SingleColumnIndexOptions, SinglePrimaryKey, SmallIntColumn, SmallSerialColumn, SomeIsTrue, SortDir, Spread, Sql, StringColumn, StringExpression, StringKey, TableData, TextBaseColumn, TextColumn, TextColumnData, Then, ThenResult, TimeColumn, TimeInterval, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, ToSqlCtx, ToSqlOptions, Transaction, TransactionAdapter, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnknownKeysParam, Update, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdatedAtDataInjector, UpsertData, UpsertResult, UpsertThis, ValidationContext, VarCharColumn, Where, WhereArg, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowFunctionOptions, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addQuestionMarks, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, applyMixins, array, arrayToEnum, baseObjectOutputType, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, flatten, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, identity, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
4308
+ export { Adapter, AdapterOptions, AddQueryJoinedTable, AddQuerySelect, AddQueryWith, AfterCallback, Aggregate, Aggregate1ArgumentTypes, AggregateArg, AggregateItem, AggregateItemArg, AggregateItemOptions, AggregateOptions, AliasOrTable, AnyColumnType, AnyColumnTypeCreator, ArrayCardinality, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AssertArray, BaseNumberData, BaseRelation, BaseStringData, BeforeCallback, BelongsToNestedInsert, BelongsToNestedUpdate, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanExpression, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ClearStatement, CoalesceString, ColumnData, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnInput, ColumnNameOfModel, ColumnOperators, ColumnOutput, ColumnParser, ColumnShapeInput, ColumnShapeOutput, ColumnType, ColumnTypes, ColumnTypesBase, ColumnsObject, ColumnsParsers, ColumnsShape, CommonQueryData, DateBaseColumn, DateColumn, DateColumnData, DateTimeBaseClass, DateTimeColumnData, DateTimeWithTimeZoneBaseClass, Db, DbOptions, DbTableOptions, DecimalBaseColumn, DecimalColumn, DecimalColumnData, DeepPartial, DefaultSelectColumns, Delete, DeleteQueryData, DoublePrecisionColumn, DropMode, EMPTY_OBJECT, EmptyObject, EnumColumn, EnumLike, Except, Expression, ExpressionOfType, ExpressionOutput, FilterTuple, For, ForeignKey, ForeignKeyModel, ForeignKeyModelWithColumns, ForeignKeyOptions, From, GetArg, HasAndBelongsToManyRelation, HasManyNestedInsert, HasManyNestedUpdate, HasManyRelation, HasOneNestedInsert, HasOneNestedUpdate, HasOneRelation, Having, HavingArg, HavingItem, IndexColumnOptions, IndexOptions, InetColumn, Insert, InsertData, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsEqual, JSONAny, JSONArray, JSONBigInt, JSONBoolean, JSONColumn, JSONDate, JSONDiscriminatedObject, JSONDiscriminatedUnion, JSONEnum, JSONInstanceOf, JSONIntersection, JSONLazy, JSONLiteral, JSONMap, JSONNaN, JSONNativeEnum, JSONNever, JSONNotNullable, JSONNotNullish, JSONNull, JSONNullable, JSONNullish, JSONNumber, JSONObject, JSONObjectShape, JSONOptional, JSONRecord, JSONRecordKeyType, JSONRequired, JSONSet, JSONString, JSONTextColumn, JSONTuple, JSONTupleItems, JSONType, JSONTypeAny, JSONTypeData, JSONTypes, JSONUndefined, JSONUnion, JSONUnknown, JSONVoid, Join, JoinArgs, JoinCallback, JoinCallbackArg, JoinItem, JoinedTablesBase, Json, JsonItem, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MaybeArray, Merge, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NestedInsertItem, NestedInsertManyItems, NestedInsertOneItem, NestedUpdateItem, NestedUpdateManyItems, NestedUpdateOneItem, NotFoundError, NullableColumn, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, NumberExpression, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrderArg, OrderItem, OutputTypeOfTuple, OutputTypeOfTupleWithRest, OwnTypeProps, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, Primitive, Query, QueryArraysResult, QueryBase, QueryCallbacks, QueryData, QueryError, QueryErrorName, QueryGet, QueryInput, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryResultRow, QueryReturnType, QueryReturnsAll, QuerySelectAll, QueryThen, QueryUpsert, QueryWithTable, RawExpression, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationsBase, Select, SelectAgg, SelectArg, SelectFunctionItem, SelectItem, SelectQueryData, Selectable, SelectableBase, SerialColumn, SetOptional, SetQueryJoinedTables, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumnInfo, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWindows, SetQueryWith, SimpleSpread, SingleColumnIndexOptions, SinglePrimaryKey, SmallIntColumn, SmallSerialColumn, SomeIsTrue, SortDir, Spread, Sql, StringColumn, StringExpression, StringKey, TableData, TextBaseColumn, TextColumn, TextColumnData, Then, ThenResult, TimeColumn, TimeInterval, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, ToSqlCtx, ToSqlOptions, Transaction, TransactionAdapter, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnknownKeysParam, Update, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdatedAtDataInjector, UpsertData, UpsertResult, UpsertThis, ValidationContext, VarCharColumn, Where, WhereArg, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowFunctionOptions, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addQuestionMarks, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, applyMixins, array, arrayToEnum, baseObjectOutputType, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, flatten, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, identity, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
package/dist/index.esm.js CHANGED
@@ -791,8 +791,9 @@ class QueryError extends DatabaseError {
791
791
  if (this.detail) {
792
792
  const list = (_a = this.detail.match(/\((.*)\)=/)) == null ? void 0 : _a[1];
793
793
  if (list) {
794
- list.split(", ").forEach((column) => {
795
- columns[column.startsWith('"') ? column.slice(1, -1) : column] = true;
794
+ list.split(", ").forEach((item) => {
795
+ const column = item.startsWith('"') ? item.slice(1, -1) : item;
796
+ columns[column] = true;
796
797
  });
797
798
  }
798
799
  }
@@ -3214,7 +3215,7 @@ const queryMethodByReturnType = {
3214
3215
  let queryError = void 0;
3215
3216
  class Then {
3216
3217
  get then() {
3217
- queryError = new QueryError();
3218
+ queryError = new Error();
3218
3219
  return maybeWrappedThen;
3219
3220
  }
3220
3221
  async catch(fn) {
@@ -3271,14 +3272,16 @@ const then = async (q, resolve, reject) => {
3271
3272
  }
3272
3273
  resolve == null ? void 0 : resolve(result);
3273
3274
  } catch (err) {
3274
- const error = err instanceof DatabaseError ? assignError(queryError, err) : err;
3275
+ const error = err instanceof DatabaseError ? assignError(q, err) : err;
3275
3276
  if (q.query.log && sql && logData) {
3276
3277
  q.query.log.onError(error, sql, logData);
3277
3278
  }
3278
3279
  reject == null ? void 0 : reject(error);
3279
3280
  }
3280
3281
  };
3281
- const assignError = (to, from) => {
3282
+ const assignError = (q, from) => {
3283
+ const to = new q.error();
3284
+ to.stack = queryError.stack;
3282
3285
  to.message = from.message;
3283
3286
  to.length = from.length;
3284
3287
  to.name = from.name;
@@ -5588,7 +5591,7 @@ class Db {
5588
5591
  const defaultSelect = this.defaultSelectColumns.length === columns.length ? void 0 : this.defaultSelectColumns;
5589
5592
  const columnsParsers = {};
5590
5593
  let hasParsers = false;
5591
- let modifyQuery;
5594
+ let modifyQuery = void 0;
5592
5595
  for (const key in shape) {
5593
5596
  const column = shape[key];
5594
5597
  if (column.parseFn) {
@@ -5609,6 +5612,8 @@ class Db {
5609
5612
  } : toSql;
5610
5613
  this.relations = {};
5611
5614
  modifyQuery == null ? void 0 : modifyQuery.forEach((cb) => cb(this));
5615
+ this.error = class extends QueryError {
5616
+ };
5612
5617
  }
5613
5618
  }
5614
5619
  applyMixins(Db, [QueryMethods]);