What do you want to change?
I use SQLC to generate data storage model, repository interfaces, and their implementations from SQL files (obviously!), and absolutely love what the tool offers. I'm constantly recommending it.
I have recently started the transition towards Clean Architecture in the project I'm work on, using a layered approach to separate concerns (e.g. domain, application, infrastructure, presentation, etc.), and unfortunately have hit a small problem with the generated SQLC files.
The interface definition of repositories (Querier in SQLC) and DSOs should live in the application layer, whereas the implementations of the repositories should live in the infrastructure layer.
At the moment, SQLC generates all files into one folder determined by the path parameter of the config.
My proposal is to allow overrides for each of the generated files. This would fix my problem, as I could generate the Querier and models in application/repository, and the SQL query strings and implementations in infrastructure/repository.
I could wrap SQLC in a custom repository interface, but I really like the fact that the repository interface and models are generated from our SQL. My temporary solution is defining a new interface that embeds the Querier, but the direction of inversion is broken, as my application layer now points to the infrastructure layer, which is incorrect in Clean Architecture. I could also just suck it up and keep SQLC files in the application layer, but then we have infrastructure concerns in the application, which is also incorrect.
Any thoughts on this? If this is something that other want/see a use for, I can take a look at opening a PR (eventually). Any input is appreciated 🙏
What database engines need to be changed?
No response
What programming language backends need to be changed?
No response
What do you want to change?
I use SQLC to generate data storage model, repository interfaces, and their implementations from SQL files (obviously!), and absolutely love what the tool offers. I'm constantly recommending it.
I have recently started the transition towards Clean Architecture in the project I'm work on, using a layered approach to separate concerns (e.g.
domain,application,infrastructure,presentation, etc.), and unfortunately have hit a small problem with the generated SQLC files.The interface definition of repositories (
Querierin SQLC) and DSOs should live in theapplicationlayer, whereas the implementations of the repositories should live in theinfrastructurelayer.At the moment, SQLC generates all files into one folder determined by the
pathparameter of the config.My proposal is to allow overrides for each of the generated files. This would fix my problem, as I could generate the
Querierand models inapplication/repository, and the SQL query strings and implementations ininfrastructure/repository.I could wrap SQLC in a custom repository interface, but I really like the fact that the repository interface and models are generated from our SQL. My temporary solution is defining a new interface that embeds the
Querier, but the direction of inversion is broken, as myapplicationlayer now points to theinfrastructurelayer, which is incorrect in Clean Architecture. I could also just suck it up and keep SQLC files in the application layer, but then we have infrastructure concerns in the application, which is also incorrect.Any thoughts on this? If this is something that other want/see a use for, I can take a look at opening a PR (eventually). Any input is appreciated 🙏
What database engines need to be changed?
No response
What programming language backends need to be changed?
No response