fix(create-adapter): disable transaction by default (#4750)

This commit is contained in:
Maxwell
2025-09-18 07:12:38 -07:00
committed by GitHub
parent 6b6ccf92a3
commit 64c5a5caed
6 changed files with 9 additions and 6 deletions
@@ -9,6 +9,7 @@ import type {
} from "../../types";
import { generateId as defaultGenerateId, logger } from "../../utils";
import type {
AdapterFactoryConfig,
AdapterFactoryOptions,
AdapterTestDebugLogs,
CleanedWhere,
@@ -69,7 +70,8 @@ export const createAdapterFactory =
supportsJSON: cfg.supportsJSON ?? false,
adapterName: cfg.adapterName ?? cfg.adapterId,
supportsNumericIds: cfg.supportsNumericIds ?? true,
};
transaction: cfg.transaction ?? false,
} satisfies AdapterFactoryConfig;
if (
options.advanced?.database?.useNumberId === true &&
@@ -99,7 +99,8 @@ export interface AdapterFactoryConfig {
* Execute multiple operations in a transaction.
*
* If the database doesn't support transactions, set this to `false` and operations will be executed sequentially.
*
*
* @default false
*/
transaction?:
| false
@@ -361,7 +361,7 @@ export const drizzleAdapter = (db: DB, config: DrizzleAdapterConfig) => {
usePlural: config.usePlural ?? false,
debugLogs: config.debugLogs ?? false,
transaction:
(config.transaction ?? true)
(config.transaction ?? false)
? (cb) =>
db.transaction((tx: DB) => {
const adapter = createAdapterFactory({
@@ -372,7 +372,7 @@ export const kyselyAdapter = (
: true,
supportsJSON: false,
transaction:
(config?.transaction ?? true)
(config?.transaction ?? false)
? (cb) =>
db.transaction().execute((trx) => {
const adapter = createAdapterFactory({
@@ -282,7 +282,7 @@ export const mongodbAdapter = (db: Db, config?: MongoDBAdapterConfig) => {
},
supportsNumericIds: false,
transaction:
config?.client && (config?.transaction ?? true)
config?.client && (config?.transaction ?? false)
? async (cb) => {
if (!config.client) {
return cb(lazyAdapter!(lazyOptions!));
@@ -241,7 +241,7 @@ export const prismaAdapter = (prisma: PrismaClient, config: PrismaConfig) => {
usePlural: config.usePlural ?? false,
debugLogs: config.debugLogs ?? false,
transaction:
(config.transaction ?? true)
(config.transaction ?? false)
? (cb) =>
(prisma as PrismaClientInternal).$transaction((tx) => {
const adapter = createAdapterFactory({