prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
39.75k stars 1.56k forks source link

Inconsistent datetime column data importing to Turso #21552

Closed bradymwilliams closed 1 year ago

bradymwilliams commented 1 year ago

Bug description

Creating a db on TURSO from the local sqlite file built from Prisma results in the following error on columns using DateTime type in schema.prisma

Conversion failed: expected a string in column createdAt, found 1697658213523.0

How to reproduce

Local Dev

  1. Setup Prisma for local sqlite development
  2. Create a model with DateTimes
  3. Seed entries into that model

Turso Setup

  1. Create a TURSO db using the local file a. turso db create test-db --from-file prisma/data.db
  2. Connect to turso via these official instructions

    21546

Query

  1. Find a row from your model by id or whatever

Expected behavior

Row gets returned without error

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

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

model Test {
  id             String               @id @unique @default(cuid())
  createdAt      DateTime             @default(now())
  updatedAt      DateTime             @default(now()) @updatedAt
}
  let test = await prisma.Test.findMany({
    where: {
      id: 'knownID',
    }
  })

Environment & setup

Prisma Version

prisma                  : 5.4.2
@prisma/client          : 5.4.2
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine ac9d7041ed77bcc8a8dbd2ab6616b39013829574 (at ../../node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli ac9d7041ed77bcc8a8dbd2ab6616b39013829574 (at ../../node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.4.1-2.ac9d7041ed77bcc8a8dbd2ab6616b39013829574
Default Engines Hash    : ac9d7041ed77bcc8a8dbd2ab6616b39013829574
Studio                  : 0.494.0
Preview Features        : driverAdapters
janpio commented 1 year ago

Thanks for the report @bradymwilliams, and trying out our Turso driver adapter. We'll look into this.

janpio commented 1 year ago

Thanks for the report @bradymwilliams. We could reproduce this and implemented a fix, which should be part of the next release.

If you don't want to wait that long or want to confirm the fix, you can install prisma@dev and @prisma/client@dev from Npm to get our development version that already includes the fix. (Don't use that long term though please.)