Skip to content

Prisma Client is unable to fetch DateTime lists #3517

@sdnts

Description

@sdnts

Bug description

Prisma Client is unable to fetch DateTime lists

How to reproduce

Use this schema:

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

datasource ds {
  provider = "postgresql"
  url      = "postgresql://siddhant@localhost:5432/experiments" // Replace
}

model User {
  id Int @id

  dateTimeList DateTime[]
}

& use this script:

import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

const main = async () => {
  await prisma.user.create({
    data: {
      id: 1,
      dateTimeList: {
        set: [
          new Date().toISOString(),
          new Date().toISOString(),
          new Date().toISOString(),
        ],
      },
    },
  });

  console.log(
    await prisma.user.findMany({
      where: {
        id: 1,
      },
    })
  );
};

main()
  .catch(async (e) => console.log(e))
  .finally(async () => {
    await prisma.$disconnect();
  });

The output of this script is:

[ { id: 1, dateTimeList: Invalid Date } ]

Expected behavior

Expected output:

[ { id: 1, dateTimeList: [

   "2020-09-03T20:28:05.886Z"
   "2020-09-03T20:28:05.886Z",
   "2020-09-03T20:28:05.886Z"
] } ]

Actual data in the DB seems to be correct AFAICT:
Screenshot 2020-09-03 at 22 30 41

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: v12.16.3
  • Prisma version:
@prisma/cli          : 2.6.1
Current platform     : darwin
Query Engine         : query-engine 6a8054bb549e4cc23f157b0010cb2e95cb2637fb (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine     : migration-engine-cli 6a8054bb549e4cc23f157b0010cb2e95cb2637fb (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core 6a8054bb549e4cc23f157b0010cb2e95cb2637fb (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary        : prisma-fmt 6a8054bb549e4cc23f157b0010cb2e95cb2637fb (at node_modules/@prisma/cli/prisma-fmt-darwin)
Studio               : 0.272.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions