Skip to content

Breaking change? Int switched to being Int32 for MongoDB #24262

@fiws

Description

@fiws

Bug description

We updated an app from prisma 5.8.1 to 5.14.0 and suddenly had to deal with integer overflows.

Turns out Prismas Int turns into Int32 with the new version.

We fixed this by adding @db.Long.

I'm just wondering: Was this intended? This effectively was a breaking change in a minor.

How to reproduce

  1. Have a prisma schema for mongodb that includes a Int
  2. Save a big value like 15552000000

Expected behavior

Gets saved as Int64 (Long)

Prisma information

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

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

model User {
  id    String @id @default(auto()) @map("_id") @db.ObjectId

  ageInMilliseconds Int      @default(31104000000) // default is 1 year in milliseconds
}
await prisma.user.create({
  ageInMilliseconds: 15552000000
});

Environment & setup

  • OS: Linux
  • Database: MongoDB
  • Node.js version: v22.2.0

Prisma Version

Environment variables loaded from .env
prisma                  : 5.14.0
@prisma/client          : 5.14.0
Computed binaryTarget   : debian-openssl-1.1.x
Operating System        : linux
Architecture            : x64
Node.js                 : v22.2.0
Query Engine (Node-API) : libquery-engine e9771e62de70f79a5e1c604a2d7c8e2a0a874b48 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Schema Engine           : schema-engine-cli e9771e62de70f79a5e1c604a2d7c8e2a0a874b48 (at node_modules/@prisma/engines/schema-engine-debian-openssl-1.1.x)
Schema Wasm             : @prisma/prisma-schema-wasm 5.14.0-25.e9771e62de70f79a5e1c604a2d7c8e2a0a874b48
Default Engines Hash    : e9771e62de70f79a5e1c604a2d7c8e2a0a874b48
Studio                  : 0.500.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions