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

Add JSON tags for input structs as well #90

Merged
merged 7 commits into from
Oct 16, 2023
Merged

Conversation

farazfazli
Copy link
Contributor

@farazfazli farazfazli commented Oct 7, 2023

Resolves #89. Two questions:

  1. How would I get the pggen.arg() name here?
  2. How can I make the spacing aligned similar to the other emitted code?

@jschaf
Copy link
Owner

jschaf commented Oct 10, 2023

Thanks for taking a crack at this:

How would I get the pggen.arg() name here?

See https://github.com/jschaf/pggen/blob/main/ARCHITECTURE.md for the high-level overview of the compilation phases. I traced the specific steps for pggen.arg below.

I think all you need to do is add RawName to TemplatedParam initialized toquery.Inputs[i].

The tests will be upset until you run make update-acceptance-test (which will cause a large diff since it updates all generated code)

Copy link
Owner

@jschaf jschaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with change to raw name

internal/codegen/golang/templated_file.go Outdated Show resolved Hide resolved
@farazfazli farazfazli marked this pull request as ready for review October 15, 2023 21:26
@farazfazli
Copy link
Contributor Author

@jschaf Changed to RawName, this is ready to be merged.

@jschaf
Copy link
Owner

jschaf commented Oct 16, 2023

Nice! Can you update the acceptance tests to fix the check and then I'll merge.

make update-acceptance-test

@farazfazli
Copy link
Contributor Author

I've gone ahead and updated the acceptance tests. Let's get this merged in and ship out a new release with these changes. Thank you @jschaf!

@jschaf jschaf merged commit 8ecc0cb into jschaf:main Oct 16, 2023
2 checks passed
@jschaf
Copy link
Owner

jschaf commented Oct 17, 2023

Released! https://github.com/jschaf/pggen/releases/tag/2023-10-16

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

Successfully merging this pull request may close these issues.

Proposal: Add CLI flag to always generate JSON tags for structs
2 participants