-
Notifications
You must be signed in to change notification settings - Fork 62
Do not return error on 0000-00-00
date
#419
base: main
Are you sure you want to change the base?
Conversation
Please land this. As it is now, it's impossible to use Prisma with legacy MySQL databases. I had to migrate to Sequelize. Sequelize! The horror. |
Hey,
I'm currently on vacation, but this makes a lot of sense to me. Back next week, going to discuss it with the team!
…On Sat, Nov 19, 2022, at 9:27 AM, Joshua Hutt wrote:
Please land this. As it is now, it's impossible to use Prisma with legacy MySQL databases. I had to migrate to Sequelize. Sequelize! The horror.
—
Reply to this email directly, view it on GitHub <#419 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAIRF5OGOSPOBR2MTJNEK3WJCFNPANCNFSM6AAAAAASE36YEE>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
@pimeys Thank you for taking a look at it, and for the careful consideration of the situation under discussion. The last option would be great – if there was a way to read them and write them as strings, and then parse them in a hook, it would work for determined users like myself who have no choice. A simple example, presented as a "workaround" for legacy databases would suffice. I wouldn't mind adding some extra code to the server to make it work–if it is possible. I couldn't figure out how to do that effectively with the current implementation, if it's even possible. If you could at least support that approach, I think we could put this issue to rest, for good. |
I put the PR for a round of reviews, and there's one thing here that does not really work well. Let's imagine you have a table: CREATE TABLE foo (
id INT NOT NULL AUTO_INCREMENT,
date DATETIME NOT NULL,
PRIMARY KEY (id)
) Now, your server lets you to write We can imagine the following model from the table: model foo {
id Int @id @default(autoincrement())
date DateTime @db.DateTime
} As we see the What options we would have here then? I'd say a few at least:
Anyhow, as it is right now we cannot merge the PR. The issue needs some product consideration before we move forward. |
@huttj could you open an issue to prisma/prisma for the feature/improvement. Then it goes to the normal rotation for the teams. |
Hey, when this pull request will be added, any ETA? |
Not in this version, I don't think it fits to the Prisma type system. See my comment in |
Not only me have such problems, just look how many comments.. |
"The default value of an optional field is null" as noted in https://www.prisma.io/docs/concepts/components/prisma-schema/data-model so can we enforce "0000-00-00 00:00:00" be recognized as NULL for data model with field model foo {
id Int @id @default(autoincrement())
date DateTime? @db.DateTime
} in this case developer can say this field is optional and can be NULL due to referenced documentation. |
I think the only thing we can do here is to let you use We just cannot convert an invalid type to null, if the Prisma type is |
it's a good starting point writing an article why we should not use prisma in our LTS projects :) |
No need to bring the discussion to this level @denisix. You could be good community member and add a comment for your use case to prisma/prisma#5006. We prioritize things our community members find important - but as you did not comment or upvote on that we for example would not know. |
Some legacy MySQL databases allow
0000-00-00
to be stored in aDate
column. However when such a value is met by prisma the whole row is discarded and cannot be retrieved and further processed.Converting an "invalid" date to NULL is a quick and dirty solution that wouldn't break anything.