drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.21k stars 565 forks source link

[BUG]:transactions options resulting in syntax error of mysql. #2133

Open sailingwithsandeep opened 5 months ago

sailingwithsandeep commented 5 months ago

What version of drizzle-orm are you using?

0.30.6

What version of drizzle-kit are you using?

0.20.14

Describe the Bug

I am migrating from prisma to drizzle. After adding transaction options i am getting syntax error:

await $.drizzleClients.queryClient.transaction(
                async tx => {
                      // some stuff.
                }
                // {
                //     isolationLevel: 'read committed',
                //     withConsistentSnapshot: true,
                //     accessMode: 'read write',
                // }
            )

Expected behavior

After removing this options it's working fine. Here is the error log:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`set transaction `' at line 1, stack: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`set transaction `' at line 1

Environment & setup

MacOS M1, 13.0.1

gss-admin commented 4 months ago

Can confirm this, using drizzle-orm@0.30.10 I needed to read uncommited in my case, added explicit commit to my transaction for now:

  await db.execute(sql`commit`);

Here is the only log with logger :true :

Query: ?? -- params: ["set transaction ", "isolation level read uncommitted"]
Serophots commented 3 months ago

I believe I'm also experiencing this on drizzle-orm@0.31.2

I think this PR is related https://github.com/drizzle-team/drizzle-orm/pull/2089

EmericW commented 2 months ago

I applied https://github.com/drizzle-team/drizzle-orm/pull/2089 as a local patch and can confirm that it fixes this issue for me.

sailingwithsandeep commented 2 weeks ago

@EmericW, just updated to latest!

I am getting same error in access mode.

EmericW commented 2 weeks ago

@sailingwithsandeep I think this should be fixed in 0.32.2, but I can't confirmed that.