-
Notifications
You must be signed in to change notification settings - Fork 813
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
Add emit_sql_as_comment
option to Go code plugin
#2735
Conversation
c0b2129
to
b2e30cb
Compare
@kyleconroy could you take a look at this PR and let me know if it's an option that could be merged in? It's a small quality-of-life improvement that really helps in our project (and behind config, off by default) Also let me know if I missed anything with the update - I wasn't 100% sure of the config changes |
Sorry for the delayed response. I understand the improved ergonomics of having the query in a godoc for certain editors but adding yet another configuration flag for a small addition to our templates system isn't a trade-off we want to make at the moment. Ideally our Go codegen would be extensible enough that you could add this without changing anything about |
We've now had at least one other request for this feature, so I'm going to reopen and attempt to rebase in order to merge. |
Thanks for picking this up again. I actually had a rebased (on v1.24) version on my fork at jasoncabot@aa15d6a |
Oh excellent. I will close my PR if you pull your rebased changes into this one. |
This option adds the raw SQL query as a comment to the generated query function This is useful when working in an IDE that displays comments over functions, you are able to glance at the actual SQL query that will be executed without having to lose context of where you are in the current file you are working on.
b2e30cb
to
db0157b
Compare
Sorry it took a while, finally got around to pushing up my changes here |
This option adds the raw SQL query as a comment to the generated query function, defaulted to false.
This is useful when working in an IDE that displays comments over functions, you are able to glance at the actual SQL query that will be executed without having to lose context of where you are in the current file you are working on.
If you have a query with comments already, it will add the query as a Code Block underneath
Input:
Output:
Example of how this shows up in VS Code when referencing the function:
If you haven't already got a comment, it will add the name of the function - I wasn't 100% sure about this but it allows the godoc comment to still have valid formatting when running
gofmt
Input:
Output:
Example of how this shows up in VS Code when referencing the function: