Skip to content

mismatch between the DateTime types of Prisma and the ones of Postgres (timestamptz unsupported) #552

Closed

Description

@infoverload

I experienced an issue with the date format after introspecting a Postgres database.

The SQL migration statements of the initial DB schema:

CREATE TABLE IF NOT EXISTS "users" ("id"   SERIAL , "username" VARCHAR(255) NOT NULL UNIQUE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));

CREATE TABLE IF NOT EXISTS "tasks" ("id"   SERIAL , "title" VARCHAR(255), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, "userId" INTEGER REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY ("id"));

The resulting Prisma data model after introspection:

model Task {
  id        Int      @id
  createdAt DateTime @default(now())
  title     String?
  updatedAt DateTime @updatedAt
  userId    User?

  @@map("tasks")
}

model User {
  id        Int      @id
  createdAt DateTime @default(now())
  tasks     Task[]
  updatedAt DateTime @updatedAt
  username  String   @unique

  @@map("users")
}

The Photon API call that caused the issue:

photon.users.findMany()

The error message:

(node:21575) UnhandledPromiseRejectionWarning: Error: 
Invalid `const users = await photon.users.findMany()` invocation in /Users/daisyt/Documents/Code/migration_sequelize_photon/src/index.ts:11:38

   7 
   8 const photon = new Photon()
   9 
  10 app.get('/users', async (req,[object Object], res) => {
→ 11     const users = await photon.users.findMany(

Error querying the database: db error: FATAL: role "user" does not exist date=2019-09-13T15:45:14.949Z
    at PhotonFetcher.<anonymous> (/Users/daisyt/Documents/Code/migration_sequelize_photon/node_modules/@generated/photon/index.js:46:27)
    at Generator.throw (<anonymous>)
    at rejected (/Users/daisyt/Documents/Code/migration_sequelize_photon/node_modules/@generated/photon/index.js:5:65)
(node:21575) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21575) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Activity

  1. pantharshit00 commented on Sep 15, 2019

    @pantharshit00
    Contributor

    I can confirm this. I think we currently don't support timestampz date fields. With [email protected], binary version: f984d2c958c73ecfc500dd44b7ed2e1081cc8588 the runtime throws the following error:

    image

    So this is related to supporting custom database types: #446

    Marking this as a feature request like we have done for other similar issues.

  2. added
    kind/feature
    on Sep 15, 2019
  3. changed the title [-]mismatch between the DateTime types of Prisma and the ones of Postgres[/-] [+]mismatch between the DateTime types of Prisma and the ones of Postgres (timestamptz unsupported)[/+] on Feb 19, 2020
  4. janpio commented on May 11, 2020

    @janpio
    Contributor

    Replaced by #2417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featuretopic: native database types

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions