Skip to content

Reproduction of a prisma issue regarding the handling of autogenerated ids

Notifications You must be signed in to change notification settings

floriantz/repro-prisma

Repository files navigation

Minimal reproduction repo for a Prisma behaviour change

Issue

The issue happened on postgresql and the behaviour changed somewhere between prisma 3.15.2 and 4.2.1.

For a given table of this structure:

CREATE TABLE repro(
    `id` UUIN NOT NULL PRIMARY KEY,
)

When querying a list of rows using an IN query clause like so:

   const rows = await this.prismaClient.$queryRaw<
    { id: string }[]
    >(Prisma.sql`
      SELECT id
      FROM repro
      WHERE id IN (${Prisma.join(ids)});
    `)

This worked fine in 3.15.2 but returns a type error in 4.2.1:

{
  "code": "P2010",
  "clientVersion": "4.2.1",
  "meta": {
    "code": "42883",
    "message": "db error: ERROR: operator does not exist: uuid = text\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts."
  }
}

This query works on the other hand:

   const rows = await this.prismaClient.$queryRaw<
    { id: string }[]
    >(Prisma.sql`
      SELECT id
      FROM repro
      WHERE id = ANY (ARRAY[${Prisma.join(ids)}]::uuid[]);
    `)

I haven't seen what would cause this in the upgrade guide and it does look like a regression to me.

Installation

Requires docker installed.

Database setup

docker compose up -d && npx prisma migrate dev

Running the script

npx ts-node main

We should not get an error for the first query.

About

Reproduction of a prisma issue regarding the handling of autogenerated ids

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published