prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
38.07k stars 1.48k forks source link

D1_ERROR: Expression tree is too large (maximum depth 100) #23919

Open hrueger opened 2 months ago

hrueger commented 2 months ago

Bug description

When using connect: string[] in an update or create query and connecting more than 100 items, it breaks when using Cloudflare D1. The error message is:

[backend] prisma:query -- Implicit "ROLLBACK" query via underlying driver
[backend] PrismaClientUnknownRequestError: 
[backend] Invalid `prisma.onlinePayout.create()` invocation:
[backend] 
[backend] 
[backend] Error occurred during query execution:
[backend] ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteError { extended_code: 1, message: Some("D1_ERROR: Expression tree is too large (maximum depth 100)") }), transient: false })
[backend]     at In.handleRequestError (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:122:7044)
[backend]     at In.handleAndLogRequestError (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:122:6188)
[backend]     at In.request (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:122:5896)
[backend]     at async l (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:127:11167)
[backend]     at async payoutNow (/Users/hannes/source/redacted/packages/backend/src/routes/(admin)/series/[series]/editions/[edition]/billing/+page.server.ts:120:30)
[backend]     at async Module.handle_action_json_request (/Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js:51:16)
[backend]     at async resolve (/Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/runtime/server/respond.js:446:18)
[backend]     at async eval (/Users/hannes/source/redacted/packages/_lib/server/logging.server.ts:28:22)
[backend]     at async Module.respond (/Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/runtime/server/respond.js:319:20)
[backend]     at async file:///Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:524:22 {
[backend]   clientVersion: '5.12.1'
[backend] }

Here's the full sql query being generated:

prisma:query UPDATE `main`.`Order` SET `onlinePayoutId` = ?, `updatedAt` = ? WHERE ((`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1))

How to reproduce

Connect more than 100 items in a relation when using the D1 adapter.

Expected behavior

It works fine and does not throw any error.

Prisma information

model Order {
  @@index([id])
  id              String        @id @default(uuid())
  amount          Int
  onlinePayout    OnlinePayout? @relation(fields: [onlinePayoutId], references: [id])
  onlinePayoutId  String?
}

model OnlinePayout {
  @@index([id])
  id     String @id @default(uuid())
  orders Order[]
}
const onlinePayout = await prisma.onlinePayout.create({
  data: {
      amount,
      orders: {
          connect: orders.map((order) => ({ id: order.id })),
      },
  },
  include: {
      orders: true
  }
});

Environment & setup

Prisma Version

prisma                  : 5.12.1
@prisma/client          : 5.12.1
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v21.6.1
Query Engine (Node-API) : libquery-engine 473ed3124229e22d881cb7addf559799debae1ab (at ../../node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli 473ed3124229e22d881cb7addf559799debae1ab (at ../../node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab
Default Engines Hash    : 473ed3124229e22d881cb7addf559799debae1ab
Studio                  : 0.499.0
janpio commented 2 months ago

Can reproduce: image

prisma:query -- Implicit "BEGIN" query via underlying driver
prisma:query INSERT INTO `main`.`User` (`email`, `name`) VALUES (?,?) RETURNING `id` AS `id`
prisma:query UPDATE `main`.`Post` SET `authorId` = ? WHERE ((`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1))
prisma:query -- Implicit "ROLLBACK" query via underlying driver
prisma:error 
Invalid `prisma.user.create()` invocation:

Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteError { extended_code: 1, message: Some("D1_ERROR: Expression tree is too large (maximum depth 100)") }), transient: false })
✘ [ERROR] Error in performIO: Error: D1_ERROR: Expression tree is too large (maximum depth 100)

      at D1Database._sendOrThrow (cloudflare-internal:d1-api:66:19)
      at async D1PreparedStatement.run (cloudflare-internal:d1-api:178:29)
      ... 2 lines matching cause stack trace ...
      at null.<anonymous> (async
  file:///workspace/prisma-d1-variables-bug/.wrangler/tmp/dev-iVxUPq/index.js:1703:18) {
    [cause]: Error: Expression tree is too large (maximum depth 100)
        at D1Database._sendOrThrow (cloudflare-internal:d1-api:67:24)
        at async D1PreparedStatement.run (cloudflare-internal:d1-api:178:29)
        at async D1Transaction.performIO
  (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/adapter-d1/dist/index.mjs:233:19)
        at async D1Transaction.executeRaw
  (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/adapter-d1/dist/index.mjs:225:17)
        at null.<anonymous> (async
  file:///workspace/prisma-d1-variables-bug/.wrangler/tmp/dev-iVxUPq/index.js:1703:18)
  }

[wrangler:err] PrismaClientUnknownRequestError: 
Invalid `prisma.user.create()` invocation:

Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteError { extended_code: 1, message: Some("D1_ERROR: Expression tree is too large (maximum depth 100)") }), transient: false })
    at or.handleRequestError (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:22:7318)
    at or.handleAndLogRequestError (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:22:6462)
    at or.request (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:22:6176)
    at async f (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:27:11094)
    at async Object.fetch (file:///workspace/prisma-d1-variables-bug/src/index.ts:23:17)
    at async jsonError (file:///workspace/prisma-d1-variables-bug/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
    at async drainBody (file:///workspace/prisma-d1-variables-bug/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
[wrangler:inf] GET / 500 Internal Server Error (1346ms)

The query triggering the failure here seems to be the one for the connect in the Prisma Client query. We need to chunk this query as well.

See full reproduction: https://github.com/janpio/prisma-d1-variables-bug/tree/janpio/23919 (Based on reproduction from https://github.com/prisma/prisma/issues/23743)