(run)
| 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 | } |
nothing calls this directly
no test coverage detected