Skip to content

Raw SELECT queries return BigInt IDs instead of Int starting at 4.4.0 #16102

Open
prisma/quaint
#422
@kkomelin

Description

@kkomelin

Bug description

Raw SELECT query returns BigInt IDs instead of Int which (again) crashes my app unexpectedly and unpredictably.
We should stop this BigInt hell once and forever.

How to reproduce

See schema and code samples below.

Expected behavior

Since I declared ID as unsigned integer I'd like to see integer in the result set (and not BigInt).

Prisma information

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model Tag {
  id                      Int             @id @default(autoincrement()) @db.UnsignedInt
  name                    String          @unique
  @@map("tags")
}

1) Correct case

const = await prisma.tag.findMany();

Returns IDs as Int (as declared in the schema):

[
 {
      id: 1,
      name: 'united states of america',
 }
]

2) Erroneous case

const tags = await prisma.$queryRawUnsafe(`select id, name from tags`)

Returns IDs as BigInt:

[
 {
      id: 1n,
      name: 'united states of america',
 }
]

Environment & setup

  • OS: Ubunu 22.04
  • Database: mariadb:10.7.5 (Docker)
  • Node.js version: node:16-alpine (Docker)

Prisma Version

The latest working version is 4.3.1.
It breaks starting from 4.4.0 and above including the latest one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedBug has been reproduced and confirmed.domain/clientIssue in the "Client" domain: Prisma Client, Prisma Studio etc.kind/bugA reported bug.topic: raw$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions