Skip to content

Cursor pagination of nested relations broken in Prisma 7 #28614

@hayes

Description

@hayes

Bug description

It looks like cursor pagination of nested relations is broken in Prisma 7

https://github.com/hayes/pothos/blob/9eb015757e6134c2f6426881f57ef49c71223c7a/packages/plugin-prisma/PRISMA_BUG_REPRODUCTION.md

Severity

⚠️ Major: Breaks core functionality (e.g., migrations fail)

Reproduction

https://github.com/hayes/pothos/blob/9eb015757e6134c2f6426881f57ef49c71223c7a/packages/plugin-prisma/PRISMA_BUG_REPRODUCTION.md

Expected vs. Actual Behavior

Querying for the same data with the same filters directly or in a nested selection yields different results (nested result returns an empty set)

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

This definitely worked in the rust engine, but I am not sure if this ever worked correctly with adapters

Workaround

Querying data without bested selections works, but for Pothos this would be massively inefficient and require a lot of refactoring

Prisma Schema & Queries

model Post {
  id        Int         @id @default(autoincrement())
  bigIntId  BigInt      @unique
  createdAt DateTime    @unique @default(now())
  updatedAt DateTime    @updatedAt
  title     String
  content   String?
  author    User        @relation(fields: [authorId], references: [id])
  authorId  Int
}

model User {
  id        Int       @id @default(autoincrement())
  email     String    @unique
  name      String?
  posts     Post[]
}
const prisma = new PrismaClient({
  adapter: new PrismaBetterSqlite3({ url: 'file:./dev.db' })
});

// ✓ WORKS
await prisma.post.findMany({
  where: { authorId: 1 },
  take: 2,
  skip: 1,
  cursor: { id: 245 },
  orderBy: { createdAt: 'desc' }
});

// ✗ FAILS (returns 0 posts instead of 2)
await prisma.user.findUnique({
  where: { id: 1 },
  include: {
    posts: {
      take: 2,
      skip: 1,
      cursor: { id: 245 },
      orderBy: { createdAt: 'desc' }
    }
  }
});

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS:
  • Database:
  • Node.js version:

Prisma Version

7.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions