Skip to content

[BUG] - Decimal ID type does not work for routing and CRUD actions #650

@DoanhThangDuc

Description

@DoanhThangDuc

Description

Description:
I have a database schema like this:

model User {
  id Decimal @id @default(dbgenerated("nextval('\"User_id_seq\"'::regclass)")) @db.Decimal(23, 0)
}

Some id values are very large, for example:
6302764515981008896

However, the value gets automatically rounded to:
6302764515981009000

When clicking on a user row, the routing uses the rounded value, and this causes the following error:

page.tsx:29  Server error: PrismaClientKnownRequestError:
Invalid `prisma.user.findUniqueOrThrow()` invocation:

An operation failed because it depends on one or more records that were required but not found.
No record was found for the query.

This happens because the rounded ID does not actually exist in the database.

So it also causes an error when performing CRUD operations, for example:

Invalid `prisma.user.update()` invocation:

An operation failed because it depends on one or more records that were required but not found.
No record was found for an update.

Reproduction URL

n/a

Reproduction steps

n/a

Next router

Page router

Next Admin version

^8.4.1

Screenshots

![DESCRIPTION](LINK.png)

Next Admin options

Logs

Browsers

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions