Skip to content

[BUG]: Cloudflare D1 transaction not supported #2463

Description

@duducpp

What version of drizzle-orm are you using?

0.31.1

What version of drizzle-kit are you using?

0.22.2

Describe the Bug

When trying to execute a transacction with cloudflare d1 adapter it throws the following error:

To execute a transaction, please use the state.storage.transaction() API instead of the SQL BEGIN TRANSACTION or SAVEPOINT statements. The JavaScript API is safer because it will automatically roll back on exceptions, and because it interacts correctly with Durable Objects' automatic atomic write coalescing.

To reproduce create a project using c3

import { drizzle } from 'drizzle-orm/d1';

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
		const db = drizzle(env.DB);

		await db.transaction(async (tx) => {
			// Throws error
		});

		return new Response('OK');
	}
};

Expected behavior

No response

Environment & setup

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions