Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with sqlc? #2968

Closed
xeoncross opened this issue Dec 20, 2021 · 5 comments
Closed

Integration with sqlc? #2968

xeoncross opened this issue Dec 20, 2021 · 5 comments

Comments

@xeoncross
Copy link

Unfortunately, Goa still requires writing some Go code. I'd like to stop this nonsense. Any chance of integrating sqlc so the entire application can be reduced to writing a few SQL statements?

@raphael
Copy link
Member

raphael commented Dec 20, 2021

Haha! Goa does support plugins which make it possible to both extend the DSL and produce different outputs. This sounds like a great application for it. There could be a simple SQL DSL function that accepts the SQL statements that the plugin would simply collect and call sqlc on. Maybe it generates some glue code between the service methods and the code generated by sqlc as well (a bit like it does today with protoc). Thanks for bringing that up - I didn't know about sqlc - looks interesting.

PS: And I can't wait for the days computers can read people's mind and autogenerate all the code (wait hmm there might be some downsides :) ).

@xeoncross
Copy link
Author

Yes, it is an interesting problem to figure out the load order. The SQL statements will be processed by sqlc and the model/store interface and entity structs generated. Then you could parse the go code using the stdlibs AST and use that to generate the service code that goa would then parse to generate it's code.

I don't think that you can run this inside the goa generation though as it has already scanned the source code by the time PrepareFunc is called - so it's too late to use the sqlc output. Perhaps I'm looking at this backwards and goa should be a plugin on sqlc, which unfortunately doesn't intend to support plugins.

@xeoncross
Copy link
Author

My mistake, seems times have changed

This will be helpful in the future when we have plugin support.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@danicc097
Copy link

It seems like times now have definitely changed and sqlc supports plugins if anyone wants to give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants