Skip to content

Turso Driver Adapter: Including _count leads to error #23566

@piotrkulpinski

Description

@piotrkulpinski

Bug description

When using Turso and attempting to generate an aggregated count, an error similar to the following is thrown

PrismaClientKnownRequestError:
Invalid `prisma.topic.findMany()` invocation:
Inconsistent column data: Conversion failed: expected a either an i64 or a f64 in column '_aggr_count_tools', found null

I think this error is thrown if the count for a specific relation equals 0.

This is the same as #23140 but that one was closed without solution.

How to reproduce

With a Turso setup, run a query similar to the following:

const topics = await prisma.topic.findMany({
  include: {
    _count: {
      select: {
        tools: true,
      },
    },
  },
})

Expected behavior

No response

Prisma information

model Tool {
  id             Int              @id @default(autoincrement())
  name           String
  slug           String           @unique
  updatedAt DateTime @updatedAt
  createdAt      DateTime         @default(now())
  topics          Topic[]
}

model Topic {
  id    Int             @id @default(autoincrement())
  name  String
  slug  String      @unique
  tools Tool[]
}

Environment & setup

  • OS: macOS
  • Database: Turso (LibSQL)
  • Bun 1.0.25

Prisma Version

5.11.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions