Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite/chinook returns PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid) on findMany() #1763

Closed
Jolg42 opened this issue Mar 3, 2020 · 10 comments
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Milestone

Comments

@Jolg42
Copy link
Member

Jolg42 commented Mar 3, 2020

chinook.db.zip
With alpha 845

/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db
11 models
- albums findMany({}) Error: 
Invalid `prisma.albums.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:568:31

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- artists findMany({}) Error: 
Invalid `prisma.artists.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:851:32

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- customers findMany({}) Error: 
Invalid `prisma.customers.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:1126:34

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- employees findMany({}) Error: 
Invalid `prisma.employees.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:1409:34

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- genres findMany({}) Error: 
Invalid `prisma.genres.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:1700:31

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- invoices findMany({}) Error: 
Invalid `prisma.invoices.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:1975:33

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- invoice_items findMany({}) Error: 
Invalid `prisma.invoice_items.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:2258:38

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- media_types findMany({}) Error: 
Invalid `prisma.media_types.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:2541:36

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- playlists findMany({}) Error: 
Invalid `prisma.playlists.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:2816:34

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- playlist_track findMany({}) Error: 
Invalid `prisma.playlist_tracks.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:3084:39

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
- tracks findMany({}) Error: 
Invalid `prisma.tracks.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/sqlite/chinook.db/index.js:3352:31

PANIC: Could not parse stored DateTime string: 2009-01-01 00:00:00: ParseError(Invalid)
generator client { 
    provider = "prisma-client-js"
    output = "../clients/sqlite/chinook.db"
  }
datasource db {
  provider = "sqlite"
  url      = "file:../sqlite_dbs/chinook.db"
}

model albums {
  AlbumId  Int      @default(autoincrement()) @id
  Title    String
  ArtistId artists
  tracks   tracks[]

  @@index([ArtistId], name: "IFK_AlbumArtistId")
}

model artists {
  ArtistId Int      @default(autoincrement()) @id
  Name     String?
  albums   albums[]
}

model customers {
  Address      String?
  City         String?
  Company      String?
  Country      String?
  CustomerId   Int        @default(autoincrement()) @id
  Email        String
  Fax          String?
  FirstName    String
  LastName     String
  Phone        String?
  PostalCode   String?
  State        String?
  SupportRepId employees?
  invoices     invoices[]

  @@index([SupportRepId], name: "IFK_CustomerSupportRepId")
}

model employees {
  Address    String?
  BirthDate  DateTime?
  City       String?
  Country    String?
  Email      String?
  EmployeeId Int         @default(autoincrement()) @id
  Fax        String?
  FirstName  String
  HireDate   DateTime?
  LastName   String
  Phone      String?
  PostalCode String?
  State      String?
  Title      String?
  ReportsTo  employees?  @relation("employeesToemployees_ReportsTo")
  customers  customers[]
  employees  employees[] @relation("employeesToemployees_ReportsTo")

  @@index([ReportsTo], name: "IFK_EmployeeReportsTo")
}

model genres {
  GenreId Int      @default(autoincrement()) @id
  Name    String?
  tracks  tracks[]
}

model invoices {
  BillingAddress    String?
  BillingCity       String?
  BillingCountry    String?
  BillingPostalCode String?
  BillingState      String?
  InvoiceDate       DateTime
  InvoiceId         Int             @default(autoincrement()) @id
  Total             Float
  CustomerId        customers
  invoice_items     invoice_items[]

  @@index([CustomerId], name: "IFK_InvoiceCustomerId")
}

model invoice_items {
  InvoiceLineId Int      @default(autoincrement()) @id
  Quantity      Int
  UnitPrice     Float
  InvoiceId     invoices
  TrackId       tracks

  @@index([TrackId], name: "IFK_InvoiceLineTrackId")
  @@index([InvoiceId], name: "IFK_InvoiceLineInvoiceId")
}

model media_types {
  MediaTypeId Int      @default(autoincrement()) @id
  Name        String?
  tracks      tracks[]
}

model playlists {
  Name       String?
  PlaylistId Int     @default(autoincrement()) @id
}

model playlist_track {
  /// This used to be part of a relation to playlists
  PlaylistId Int
  /// This used to be part of a relation to tracks
  TrackId    Int

  @@id([PlaylistId, TrackId])
  @@index([TrackId], name: "IFK_PlaylistTrackTrackId")
}

model tracks {
  Bytes         Int?
  Composer      String?
  Milliseconds  Int
  Name          String
  TrackId       Int             @default(autoincrement()) @id
  UnitPrice     Float
  AlbumId       albums?
  GenreId       genres?
  MediaTypeId   media_types
  invoice_items invoice_items[]

  @@index([MediaTypeId], name: "IFK_TrackMediaTypeId")
  @@index([GenreId], name: "IFK_TrackGenreId")
  @@index([AlbumId], name: "IFK_TrackAlbumId")
}
@divyenduz
Copy link
Contributor

More context with DEBUG=*

The error message needs to follow the error spec besides the bug.

CleanShot 2020-03-03 at 14 51 34@2x

@janpio janpio transferred this issue from prisma/prisma-client-js Mar 4, 2020
@janpio janpio added this to the Preview 24 New milestone Mar 4, 2020
@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. labels Mar 4, 2020
@divyenduz divyenduz modified the milestones: Preview 24 New, Preview 25 Mar 13, 2020
@Jolg42
Copy link
Member Author

Jolg42 commented Mar 16, 2020

With query generator on alpha 908 the error format changed

- albums findMany({}) Error: 
Invalid `prisma.albums.findMany()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/query.ts:86:75
PANIC: called `Result::unwrap()` on an `Err` value: ErrorMessage { msg: "Could not parse stored DateTime string: 2009-01-01 00:00:00 (input contains invalid characters)" }
   0: failure::backtrace::internal::InternalBacktrace::new
   1: <failure::backtrace::Backtrace as core::default::Default>::default
   2: sql_query_connector::row::row_value_to_prisma_value
   3: <quaint::connector::result_set::result_row::ResultRow as sql_query_connector::row::ToSqlRow>::to_sql_row
   4: <std::future::GenFuture<T> as core::future::future::Future>::poll
   5: std::future::poll_with_tls_context
   6: <std::future::GenFuture<T> as core::future::future::Future>::poll
   7: <std::future::GenFuture<T> as core::future::future::Future>::poll
   8: <std::future::GenFuture<T> as core::future::future::Future>::poll
   9: <std::future::GenFuture<T> as core::future::future::Future>::poll
  10: <std::future::GenFuture<T> as core::future::future::Future>::poll
  11: std::future::poll_with_tls_context
  12: <std::future::GenFuture<T> as core::future::future::Future>::poll
  13: <std::future::GenFuture<T> as core::future::future::Future>::poll
  14: std::panicking::try::do_call
  15: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  16: <std::future::GenFuture<T> as core::future::future::Future>::poll
  17: tokio::task::core::Core<T>::poll
  18: std::panicking::try::do_call
  19: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  20: tokio::task::harness::Harness<T,S>::poll
  21: tokio::runtime::thread_pool::worker::GenerationGuard::run_task
  22: tokio::runtime::thread_pool::worker::GenerationGuard::run
  23: std::thread::local::LocalKey<T>::with
  24: tokio::runtime::thread_pool::worker::Worker::run
  25: tokio::task::core::Core<T>::poll
  26: std::panicking::try::do_call
  27: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  28: tokio::task::harness::Harness<T,S>::poll
  29: tokio::runtime::context::enter
  30: std::sys_common::backtrace::__rust_begin_short_backtrace
  31: std::panicking::try::do_call
  32: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  33: core::ops::function::FnOnce::call_once{{vtable.shim}}
  34: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/f3e1a954d2ead4e2fc197c7da7d71e6c61bad196/src/liballoc/boxed.rs:1022
  35: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/f3e1a954d2ead4e2fc197c7da7d71e6c61bad196/src/liballoc/boxed.rs:1022
      std::sys_common::thread::start_thread
             at src/libstd/sys_common/thread.rs:13
      std::sys::unix::thread::Thread::new::thread_start
             at src/libstd/sys/unix/thread.rs:80
  36: start_thread
  37: __clone

@janpio
Copy link
Member

janpio commented Mar 19, 2020

I can not confirm this any more:

const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

prisma.albums.findMany().then(res => {
    console.log(res)
})
C:\Users\Jan\Documents\throwaway\1763>node index.js
[
  { AlbumId: 1, Title: 'For Those About To Rock We Salute You' },
  { AlbumId: 2, Title: 'Balls to the Wall' },
  { AlbumId: 3, Title: 'Restless and Wild' },
  { AlbumId: 4, Title: 'Let There Be Rock' },
...

Can you please check if you can still confirm this @Jolg42 and/or @divyenduz?

@janpio janpio assigned divyenduz and Jolg42 and unassigned mavilein and do4gr Mar 19, 2020
@Jolg42
Copy link
Member Author

Jolg42 commented Mar 20, 2020

Fixed in latest alpha ✅ 🎊

@Jolg42 Jolg42 closed this as completed Mar 20, 2020
@jschank
Copy link

jschank commented Jun 9, 2020

I still get this error in @prisma/cli ver 2.0.0
How do I ensure i am using the version with this fix?

@pantharshit00
Copy link
Contributor

@jschank Please open an new issue with a minimal reproduction. Thanks!

@jschank
Copy link

jschank commented Jun 13, 2020

I think I see the problem. When I create a new sqlite3 database using prisma and write data into the db programmatically. I can both read and write data with dates.

However, when I try to generate a prisma Client using introspection of an existing database. that is where this fails.

The existing database was created with typeORM and the date is written as '2020-05-31 21:11:22.000', On the other hand, prisma writes the data to the db as '1591999869569'

IF anything this maybe an issue with what the introspection process decides about the data it sees.

@janpio
Copy link
Member

janpio commented Jun 15, 2020

Yes, please open a new issue with all the information and we can take a look, reproduce and hopefully fix it @jschank.

@MOTORIST
Copy link

MOTORIST commented Jun 16, 2020

Hi!
I have the same problem (.
DB: sqlite

Emitting error {
  timestamp: 2020-06-16T22:41:44.829Z,
  level: 'error',
  target: 'query_engine',
  fields: {
    message: 'PANIC',
    reason: 'called `Result::unwrap()` on an `Err` value: ErrorMessage { msg: "Could not parse stored DateTime string: 2011-10-31 20:00:00.000 +00:00 (input contains invalid characters)" }\n' +
      '\n' +
      '   0: backtrace::backtrace::trace\n' +
      '   1: backtrace::capture::Backtrace::new_unresolved\n' +
      '   2: failure::backtrace::internal::InternalBacktrace::new\n' +
      '   3: <failure::backtrace::Backtrace as core::default::Default>::default\n' +
      '   4: sql_query_connector::row::row_value_to_prisma_value\n' +
      '   5: <quaint::connector::result_set::result_row::ResultRow as sql_query_connector::row::ToSqlRow>::to_sql_row\n' +
      '   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  17: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  18: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  19: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n' +
      '  20: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch\n' +
      '  21: <hyper::server::conn::ProtoServer<T,B,S,E> as core::future::future::Future>::poll\n' +
      '  22: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll\n' +
      '  23: <hyper::server::conn::spawn_all::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll\n' +
      '  24: tokio::task::core::Core<T>::poll\n' +
      '  25: tokio::task::harness::Harness<T,S>::poll\n' +
      '  26: tokio::runtime::thread_pool::worker::GenerationGuard::run_task\n' +
      '  27: tokio::runtime::thread_pool::worker::GenerationGuard::run\n' +
      '  28: std::thread::local::LocalKey<T>::with\n' +
      '  29: tokio::runtime::thread_pool::worker::Worker::run\n' +
      '  30: tokio::task::core::Core<T>::poll\n' +
      '  31: tokio::task::harness::Harness<T,S>::poll\n' +
      '  32: tokio::runtime::blocking::pool::Inner::run\n' +
      '  33: tokio::runtime::context::enter\n' +
      '  34: std::sys_common::backtrace::__rust_begin_short_backtrace\n' +
      '  35: core::ops::function::FnOnce::call_once{{vtable.shim}}\n' +
      '  36: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once\n' +
      '             at /rustc/49cae55760da0a43428eba73abcb659bb70cf2e4\\src\\liballoc/boxed.rs:1008\n' +
      '      <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once\n' +
      '             at /rustc/49cae55760da0a43428eba73abcb659bb70cf2e4\\src\\liballoc/boxed.rs:1008\n' +
      '      std::sys::windows::thread::Thread::new::thread_start\n' +
      '             at /rustc/49cae55760da0a43428eba73abcb659bb70cf2e4\\/src\\libstd\\sys\\windows/thread.rs:56\n' +
      '  37: sqlite3GenerateConstraintChecks\n' +
      '  38: sqlite3GenerateConstraintChecks\n',
    file: 'query-engine/connectors/sql-query-connector/src/row.rs',
    line: 119,
    column: 26
  }
}

@pantharshit00
Copy link
Contributor

Please open a new issue with a reproduction @MOTORIST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

8 participants