valtyr/prisma-kysely

@map for table fields is incorrect

annibuliful opened this issue ยท 8 comments

Screenshot 2566-03-19 at 22 21 54

When I set map `action` to `map_action` on database level it's not when generate.

As you see it should me map_action not action
Screenshot 2566-03-19 at 22 23 44

valtyr commented

Hey again @annibuliful. I spent some time looking into this and it seems like Prisma don't provide information about field mappings to generators. Check out this issue: prisma/prisma#3998. For the time being, I don't think there's any reasonable way to support this. Sorry about that ๐Ÿ˜ž

In the meantime, you should just be able to call the field map_action. I know it's ugly to have a single snake case field... but probably better than not having access to the field at all?

Awesome to have someone like you using the library and reporting issues. It's super valuable, thank you again ๐Ÿ˜„

valtyr commented

I've added a section to the README that explains this

janpio commented

Please make sure to leave a comment on prisma/prisma#3998 that mentions that this leads to a limitation in your custom generator - we will take this into account with prioritization. Thanks.

(๐Ÿ‘‹ from @prisma)

valtyr commented

@janpio Done! Cool to see someone form Prisma lurking here. I appreciate you reaching out ๐Ÿ‘‹ ๐ŸŽ‰

I was just working on a generator myself, and it looks like this does exist - DMMF.Field has a property that gets filled out with @map statements called dbName. Note that it's incorrect on the typings, which denote it as an array called dbNames. I have a pending PR for that

valtyr commented

@luxaritas Awesome, thanks for letting me know. I'll look into this.

valtyr commented

I've made a first pass at adding support for this in pr #22. Here's a snapshot version for you guys to try: 0.0.0-snapshot-20230420160205. @annibuliful

Thank you so much