fdarian / prisma-generator-drizzle

A Prisma generator for generating Drizzle schema with ease
113 stars 11 forks source link

No support for native DB Types #74

Open jansedlon opened 1 week ago

jansedlon commented 1 week ago

prisma-generator-drizzle doesn't support @db.XX.

Because it can't, prisma doesn't provide information about this.

My idea was to support this via directives, likes /// drizzle.dbType xx. So basically local overrides

I have few fields which are DateTime @db.Time but this is generated as datetime(). When i query this column, drizzle returns this as Invalid Date so it's basically unusable.

I have a prototype ready for my use case, so will clean the code a bit and make a PR. What do you think about this approach?

fdarian commented 1 week ago

I prefer building our own parser to support @db.XX. The built-in generator lacks several key features as well, such as relationship information.

I've already developed the prototype but still in playground. The implementation turned out not to be that complex.

But the ability to modify such things should be accommodated with the drizzle.custom, which still in pr currently

fdarian commented 1 week ago

If you fancy adding a PR, I think field.func combined with field.import should be good. Similar to this.

Or maybe we could make field.coreFunc to automate the import.

jansedlon commented 1 week ago

Not sure if you mean the same thing by your own parser, but you can take look here https://github.com/MrLeebo/prisma-ast

fdarian commented 1 week ago

Ahh, will definitely try