-
Notifications
You must be signed in to change notification settings - Fork 29
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
Proposal: Add CLI flag to always generate JSON tags for structs #89
Comments
Do you mean adding JSON tags to the input structs as well? Is the idea you take JSON that directly matches the input parameters? |
@jschaf Hey thanks for replying so quickly. Yes exactly, that's what I had in mind. What are your thoughts on this? |
I think adding JSON tags is okay. Two thoughts:
Do those thoughts impact your use-case? |
Glad to hear that. To address your points:
Check constraints can be used on the underlying tables for validating things on the database side. I feel validating things is up to the developer to enforce more-so than the tooling making it easier or harder. I do understand your point though.
Views can be created as an abstraction over Postgres tables, hiding the implementation details of the underlying tables from the public API. That way, the tables can evolve over time while the views remain stable. |
It looks like a few things are needed to get this to work:
Is this approach correct? If so, happy to open a PR with these changes. Would just need your help to get some tests written for this functionality. Thank you. :) |
The interesting decision is what to use for the JSON tag name. Options are:
Any preference? The main change would be in:
And look very similar to:
I'm happy to talk you through it if you want to send a PR. |
Ok - I made it emit by default. Regarding the options, I think the first option is the best as this is customizable which is useful to the user. I opened a draft PR, please see #90. Interested in hearing your feedback. |
Right now JSON struct tags are only generated for
<query_name>Row
structs according to the README.What are your thoughts on adding a CLI flag (such as
--json-struct-tags
) to always generate JSON tags whenever structs are generated? This would be useful while building REST APIs.Looking forward to hearing back. Thanks again for the great project!
The text was updated successfully, but these errors were encountered: