feat(generator): support custom default casing for client properties
Change Summary
model UserProfile {
...
}
this code generate prisma class attributes like prisma.userprofile, which is sometimes very hard to read
i suggest having default attribute name as prisma.user_profile with using jinja2_strcase package.
Checklist
- [x] Unit tests for the changes exist
- [x] Tests pass without significant drop in coverage
- [ ] Documentation reflects changes where applicable
- [x] Test snapshots have been updated if applicable
Agreement
By submitting this pull request, I confirm that you can use, modify, copy and redistribute this contribution, under the terms of your choice.
Thanks! Unfortunately, this is a breaking change so I'd like to first introduce this using a config option, e.g.
generator client {
provider = "prisma-client-py"
client_casing = "snake_case"
}
I'm also a little hesitant to introduce this new dependency, would it be feasible to do this without that? or at least using a popular package for changing case?
It's also worth noting that longer term, I want to support customising this more freely, e.g. (structure still TBD)
/// @Python(instance_name: 'user_foo')
model UserFoo {
// ...
}
FYI I cherry picked your change case util functions into a separate PR as I needed them for something else, #918.
I tried to rebase your PR for you to resolve the merge conflicts but it looks like I don't have permission to push to your fork, could you open a separate PR with edit perms and from a different branch? (i.e. a branch that isn't main on your fork)
New PR has opened with edit permission https://github.com/RobertCraigie/prisma-client-py/pull/922
Please check it out and let me know if you need anything for help :)