Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

sqlc for Hexagonal architecture? #944

Unanswered
idirall22 asked this question in Feature Requests & Ideas
Discussion options

Hey there, awesome library!
Currently, I'm building a service based on hexagonal architecture, and I use sqlc to generate Golang code.
The issue for me is that the querier interface, the parameters, and models are generated with the implementation.
As we want to keep things open, we are wondering if there is a solution to move the querier interface, the parameters, and models outside of the output folder?
Also is there a way to convert the sql.NullString to a *string so the data type could be generic, not specific to SQL?

You must be logged in to vote

Replies: 2 comments

Comment options

Yeah I would also like to be able to change the output location for each generated file. Below is what I think would be the most logical fit for an existing hexagonal architecture. Also be able to specify different package for each.

models.go -> internal/domain
querier.go -> internal/core/ports/services.go
? -> internal/core/ports/repositories.go
query.sql.go -> internal/services/usersrv/service.go
db.go -> maybe the Queries struct and Methods can be split into internal/repositories/postgres/user.go (as it is actual implementation)

You must be logged in to vote
0 replies
Comment options

I suggest you consider the sqlc gen code as an adapter only and do the mapping with your domain structs instead of directly use the sqlc models as your domain

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /