Skip to content

Commit e509560

Browse files
committed
fix mssql transaction not working when client is AutoPool
1 parent b705c25 commit e509560

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drizzle-orm/src/node-mssql/session.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ export class NodeMsSqlSession<
244244
transaction: (tx: NodeMsSqlTransaction<TFullSchema, TSchema>) => Promise<T>,
245245
config?: MsSqlTransactionConfig,
246246
): Promise<T> {
247-
const mssqlTransaction = (this.client as ConnectionPool).transaction();
247+
let queryClient = this.client as ConnectionPool;
248+
if (is(this.client, AutoPool)) {
249+
queryClient = await this.client.$instance();
250+
}
251+
const mssqlTransaction = queryClient.transaction();
248252
const session = new NodeMsSqlSession(
249253
mssqlTransaction,
250254
this.dialect,

0 commit comments

Comments
 (0)