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
21.47k stars 486 forks source link

[BUG]: D1 too many SQL variables at offset #2479

Open jamiehaywood opened 3 weeks ago

jamiehaywood commented 3 weeks ago

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.1

Describe the Bug

When running an insert() query with more than 32 values, D1 throws error: too many SQL variables at offset.

Expected behavior

Expect Drizzle to chunk the inserts similar to Prisma

Environment & setup

const sqlite = new Database("db.sqlite");

const db = drizzle<typeof schema>(sqlite, { schema });

const books = new Array(35).fill({}).map((b, i) => ({
  id: i.toString(),
  title: "The Great Gatsby",
  description: "A book about a rich guy",
}));

await db.insert(schema.books).values(books);
ktKongTong commented 1 day ago

Same issue. Checked Cloudflare docs and found that D1 limits queries to 100 bound parameters max.

https://developers.cloudflare.com/d1/platform/limits/

it's work for me.