DateTime values wrongly typed in Prisma Client
See original GitHub issueBug description
When using start
as an ISO string in a date library, I get this error. There are no runtime errors as it’s actually a string:
// Argument of type [see below] is not assignable to parameter of type 'string'
DateTime.fromISO(start)
Prisma schema
start DateTime
Lets console.log(start)
1970-01-01T00:00:00.000Z
TypeScript type for start
start: {
toString: () => string;
toDateString: () => string;
toTimeString: () => string;
toLocaleString: {
(): string;
(locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): string;
};
... 40 more ...;
[Symbol.toPrimitive]: {
...;
};
}
Prisma Version
prisma : 3.11.1
@prisma/client : 3.11.1
Current platform : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine : migration-engine-cli 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 1a2506facaf1a4727b7c26850735e88ec779dee9
Studio : 0.458.0
Preview Features : fullTextSearch
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Error message reference - Prisma
Prisma Client throws a PrismaClientInitializationError exception if something goes wrong when the query engine is started and the connection to the database ...
Read more >Prisma Schema not updating properly after adding new fields
It seems like the operation is using a previous version of the schema seeing as how it says that the email field does...
Read more >prisma datetime null - You.com | The Search Engine You Control
Prisma 2 unable to fetch DateTime column with null value ... Value out of range for the type. ... Prisma client not marking...
Read more >Prisma 3.14.0 Release - GitClear
Prisma Client queries such as findMany deserialize database scalar values to their corresponding JavaScript types. For example, a DateTime ...
Read more >It's Prisma Time - Create Table - DEV Community
The published property is of type Boolean and its default value is false; The createAt is of type DateTime and when a new...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just have the same problem
@ekerik220 in your case Prisma returns a Date. It is then lost and converted to a string due to serialization to JSON by Remix. You can see what’s happening by adding some logs on the server side as well.
Logs:
Diff: