Seeking feedback before working on a generator for sqlc #4370
Unanswered
toniphan21
asked this question in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I am seeking feedback before working on a generator for sqlc. To be clear, there is nothing changed on the
sqlcside - it is just a tool to integrate/usesqlc.Problem
sqlcis a great alternative for ORM. It is an infrastructure layer, but I do not often start with infra - I start with the domain part. Say I have adomainwith simple things:Then I work with the storer and entity. After finishing the
domainlogic, I start to think about infra. At this point I usesqlclike this:and the sqlc emitted code looks like this:
Then the next step is to implement
UserStorer, which contains a lot of mapping:CreateUserInput→CreateUserParamsmodel.User→domain.UserI find that there is a lot of space that could be automated:
user.sqlbased on the signature, but to generate boilerplate sql that I could manually edit if needed.sqlcto generate the mapper automatically.I am also having a mapping solution (go-mapper-gen) but it is currently in a heavy rewrite to align with my other tools.
What I think I need to build
go-sqlc-gen: a generator that generates boilerplate for sqlc config and mapping configuration.go-mapper-gen: a generator that reads the mapping configuration and the sqlc emitted code, then generates the entity mapper and storer implementation.So if everything works as expected, the workflow will look like this:
go-sqlc-gento generate standard boilerplate for sqlc.sqlc.yamland.sql.sqlcandgo-mapper-gento generate the implementation from the domain. Ideally, both tools run seamlessly in a single step.Before I start building, I'd love to hear from anyone who has used
sqlcmore deeply than I have:sqlcalready solve this? I may have missed a feature or plugin that handles the domain → infra mapping boilerplate I described.Thank you for reading and for any feedback you can share!
Beta Was this translation helpful? Give feedback.
All reactions