prisma / prisma-test-utils

A collection of data model agnostic test utils.
112 stars 10 forks source link

PANIC: invalid or out-of-range date for type timestamp #33

Open divyenduz opened 4 years ago

divyenduz commented 4 years ago

According to the MySQL docs: The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

test-utils however is not aware of this limitation as this information is lost in the Prisma schema (timestamp is mapped to Prisma type DateTime).

A potential solution in test-utils can be to cap all date time types to the smaller date time range of all the underlying types (in my understanding that is indeed timestamp)


Internal notes:

Test utils database(s) affected:


Related issue: https://github.com/prisma/prisma-test-utils/issues/20

I don't know how Jan was able to make Sakila run, in my automated tests, it fails on the generate step. The underlying field there is timestamp but the error is slightly different. Maybe it morphed.

janpio commented 4 years ago

A potential solution in test-utils can be to cap all date time types to the smaller date time range of all the underlying types

That sounds like the right thing to do here. Creating timestamps in that date range should be simple enough.

divyenduz commented 4 years ago

A potential solution in test-utils can be to cap all date time types to the smaller date time range of all the underlying types

Added this in a test-utils branch. Update (will move this content to its respective place/issue tomorrow!):


Looks like this issue is effectively resolved.