Skip to content

Inconsistent column data: Unexpected conversion failure from String to datetime. Reason: $trailing input #22293

@rajdtta

Description

@rajdtta

Bug description

I updated Prisma from v5.6 to v5.7 (to test out the experimental join feature). When the feature was enabled, my application started erroring with the following message:

Invalid `prisma.userProfile.findUniqueOrThrow()` invocation:

Inconsistent column data: Unexpected conversion failure from String(2023-12-06T17:43:39.515686+00:00) to DateTime. Reason: $trailing input
    at async UserDBO.getUserByID (./app/api/user/source.ts:67:16)
    at async UserService.getSessionUser (./app/api/user/service.ts:58:16)
    at async DashboardPage (dashboard/page.tsx:52:25)
digest: "3975094782"

How to reproduce

All I did was upgrade from Prisma v5.6 to v5.7. If I can figure out how to replicate the issue consistently from a sandbox, I'll follow up with an instruction set.

Expected behavior

I would expect these queries to execute w/o any issues given that they worked completely fine in the past.

Prisma information

model UserProfile {
  userId           String             @id @db.Uuid
  avatar_url       String?
  companyId        String             @db.Uuid
  createdAt        DateTime           @default(now())
  updatedAt        DateTime           @updatedAt
  companyRole      COMPANY_ROLE       @default(USER)
  role             USER_ROLE          @default(USER)
  firstName        String
  lastName         String
  phone            String
  dashboards       Dashboard[]
  DashboardPresets DashboardPresets[]
  company          Company            @relation(fields: [companyId], references: [id], onDelete: Cascade)
  user             users              @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@schema("platform_db")
}

model Company {
  id               String                 @id @default(uuid()) @db.Uuid
  name             String
  createdAt        DateTime               @default(now())
  updatedAt        DateTime               @updatedAt
  deletedAt        DateTime?
  ownerId          String                 @unique @db.Uuid
  stripeCustomerId String?
  stripeTestId     String?
  owner            users                  @relation(fields: [ownerId], references: [id], onDelete: Cascade)
  subscriptions    CompanySubscriptions[]
  DashboardPresets DashboardPresets[]
  User             UserProfile[]

  @@schema("platform_db")
}


model users { // Supabase's user table
  instance_id                 String?       @db.Uuid
  id                          String        @id @db.Uuid
  aud                         String?       @db.VarChar(255)
  role                        String?       @db.VarChar(255)
  email                       String?       @db.VarChar(255)
  encrypted_password          String?       @db.VarChar(255)
  email_confirmed_at          DateTime?     @db.Timestamptz(6)
  invited_at                  DateTime?     @db.Timestamptz(6)
  confirmation_token          String?       @db.VarChar(255)
  confirmation_sent_at        DateTime?     @db.Timestamptz(6)
  recovery_token              String?       @db.VarChar(255)
  recovery_sent_at            DateTime?     @db.Timestamptz(6)
  email_change_token_new      String?       @db.VarChar(255)
  email_change                String?       @db.VarChar(255)
  email_change_sent_at        DateTime?     @db.Timestamptz(6)
  last_sign_in_at             DateTime?     @db.Timestamptz(6)
  raw_app_meta_data           Json?
  raw_user_meta_data          Json?
  is_super_admin              Boolean?
  created_at                  DateTime?     @db.Timestamptz(6)
  updated_at                  DateTime?     @db.Timestamptz(6)
  phone                       String?       @unique
  phone_confirmed_at          DateTime?     @db.Timestamptz(6)
  phone_change                String?       @default("")
  phone_change_token          String?       @default("") @db.VarChar(255)
  phone_change_sent_at        DateTime?     @db.Timestamptz(6)
  confirmed_at                DateTime?     @default(dbgenerated("LEAST(email_confirmed_at, phone_confirmed_at)")) @db.Timestamptz(6)
  email_change_token_current  String?       @default("") @db.VarChar(255)
  email_change_confirm_status Int?          @default(0) @db.SmallInt
  banned_until                DateTime?     @db.Timestamptz(6)
  reauthentication_token      String?       @default("") @db.VarChar(255)
  reauthentication_sent_at    DateTime?     @db.Timestamptz(6)
  is_sso_user                 Boolean       @default(false)
  deleted_at                  DateTime?     @db.Timestamptz(6)
  identities                  identities[]
  mfa_factors                 mfa_factors[]
  sessions                    sessions[]
  Company                     Company?
  UserProfile                 UserProfile?

  @@index([instance_id])
  @@schema("auth")
}
await prisma.userProfile.findUniqueOrThrow({
      where: {
        userId: userID,
      },
      select: {
        userId: true,
        avatar_url: true,
        firstName: true,
        lastName: true,
        phone: true,
        role: true,
        companyRole: true,
        company: {
          select: {
            name: true,
            id: true,
            ownerId: true,
          },
        },
        user: {
          select: {
            email: true,
            last_sign_in_at: true,
            confirmed_at: true,
            created_at: true,
          },
        },
      },
    });

Environment & setup

  • OS: macOS 14.1
  • Database: PostgreSQL (using Prisma Accelerate for pooling)
  • Node.js version: v21.2.0

Prisma Version

prisma                  : 5.7.0
@prisma/client          : 5.7.0
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v21.2.0
Query Engine (Node-API) : libquery-engine 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.7.0-41.79fb5193cf0a8fdbef536e4b4a159cad677ab1b9
Default Engines Hash    : 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9
Studio                  : 0.495.0
Preview Features        : fullTextSearch, multiSchema, postgresqlExtensions

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions