MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / transaction

Function transaction

packages/core/fumadb/src/adapters/drizzle/query.ts:405–430  ·  view source on GitHub ↗
(run)

Source from the content-addressed store, hash-verified

403 await query;
404 },
405 async transaction(run) {
406 // Some SQLite-compatible engines (Cloudflare D1) reject interactive
407 // transactions — both raw BEGIN/COMMIT and the driver's `.transaction()`.
408 // When disabled, run the operations directly against the same connection:
409 // each statement auto-commits, so there is no atomic rollback (the
410 // engine's constraint, not ours). libSQL/Postgres keep real transactions.
411 if (!interactiveTransactions) {
412 return run(fromDrizzle(schema, _db, provider, interactiveTransactions, maxBoundParameters));
413 }
414
415 if (provider === "sqlite") {
416 await executeRaw("BEGIN");
417 try {
418 const result = await run(fromDrizzle(schema, _db, provider, interactiveTransactions, maxBoundParameters));
419 await executeRaw("COMMIT");
420 return result;
421 } catch (e) {
422 await executeRaw("ROLLBACK");
423 throw e;
424 }
425 }
426
427 return db.transaction((tx) =>
428 run(fromDrizzle(schema, tx, provider, interactiveTransactions, maxBoundParameters))
429 );
430 },
431 });
432}

Callers

nothing calls this directly

Calls 4

fromDrizzleFunction · 0.85
executeRawFunction · 0.85
runFunction · 0.70
transactionMethod · 0.65

Tested by

no test coverage detected