Skip to content

Commit 8b8d78e

Browse files
Fix export of DrizzleQueryError (fixes #4618) (#4778)
* Fix export of `DrizzleQueryError` (fixes #4618) There was a module name clash of `src/errors.ts` and `src/errors/index.ts`. This commit moves `DrizzleQueryError` into `src/errors.ts` and removes the module clash to fix the issue. * Changelog --------- Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
1 parent 027921f commit 8b8d78e

File tree

9 files changed

+21
-24
lines changed

9 files changed

+21
-24
lines changed

changelogs/drizzle-orm/0.44.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix wrong DrizzleQueryError export. thanks @nathankleyn

drizzle-orm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drizzle-orm",
3-
"version": "0.44.3",
3+
"version": "0.44.4",
44
"description": "Drizzle ORM package for SQL databases",
55
"type": "module",
66
"scripts": {

drizzle-orm/src/errors.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ export class DrizzleError extends Error {
1010
}
1111
}
1212

13+
export class DrizzleQueryError extends Error {
14+
constructor(
15+
public query: string,
16+
public params: any[],
17+
public override cause?: Error,
18+
) {
19+
super(`Failed query: ${query}\nparams: ${params}`);
20+
Error.captureStackTrace(this, DrizzleQueryError);
21+
22+
// ES2022+: preserves original error on `.cause`
23+
if (cause) (this as any).cause = cause;
24+
}
25+
}
26+
1327
export class TransactionRollbackError extends DrizzleError {
1428
static override readonly [entityKind]: string = 'TransactionRollbackError';
1529

drizzle-orm/src/errors/index.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

drizzle-orm/src/gel-core/session.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';
22
import type { WithCacheConfig } from '~/cache/core/types.ts';
33
import { entityKind, is } from '~/entity.ts';
4-
import { TransactionRollbackError } from '~/errors.ts';
5-
import { DrizzleQueryError } from '~/errors/index.ts';
4+
import { DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';
65
import type { TablesRelationalConfig } from '~/relations.ts';
76
import type { PreparedQuery } from '~/session.ts';
87
import type { Query, SQL } from '~/sql/index.ts';

drizzle-orm/src/mysql-core/session.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';
22
import type { WithCacheConfig } from '~/cache/core/types.ts';
33
import { entityKind, is } from '~/entity.ts';
4-
import { TransactionRollbackError } from '~/errors.ts';
5-
import { DrizzleQueryError } from '~/errors/index.ts';
4+
import { DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';
65
import type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';
76
import { type Query, type SQL, sql } from '~/sql/sql.ts';
87
import type { Assume, Equal } from '~/utils.ts';

drizzle-orm/src/pg-core/session.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';
22
import type { WithCacheConfig } from '~/cache/core/types.ts';
33
import { entityKind, is } from '~/entity.ts';
4-
import { TransactionRollbackError } from '~/errors.ts';
5-
import { DrizzleQueryError } from '~/errors/index.ts';
4+
import { DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';
65
import type { TablesRelationalConfig } from '~/relations.ts';
76
import type { PreparedQuery } from '~/session.ts';
87
import { type Query, type SQL, sql } from '~/sql/index.ts';

drizzle-orm/src/singlestore-core/session.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';
22
import type { WithCacheConfig } from '~/cache/core/types.ts';
33
import { entityKind, is } from '~/entity.ts';
4-
import { TransactionRollbackError } from '~/errors.ts';
5-
import { DrizzleQueryError } from '~/errors/index.ts';
4+
import { DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';
65
import type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';
76
import { type Query, type SQL, sql } from '~/sql/sql.ts';
87
import type { Assume, Equal } from '~/utils.ts';

drizzle-orm/src/sqlite-core/session.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { type Cache, hashQuery, NoopCache } from '~/cache/core/cache.ts';
22
import type { WithCacheConfig } from '~/cache/core/types.ts';
33
import { entityKind, is } from '~/entity.ts';
4-
import { DrizzleError, TransactionRollbackError } from '~/errors.ts';
5-
import { DrizzleQueryError } from '~/errors/index.ts';
4+
import { DrizzleError, DrizzleQueryError, TransactionRollbackError } from '~/errors.ts';
65
import { QueryPromise } from '~/query-promise.ts';
76
import type { TablesRelationalConfig } from '~/relations.ts';
87
import type { PreparedQuery } from '~/session.ts';

0 commit comments

Comments
 (0)