jschaf / pggen

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.
MIT License
281 stars 26 forks source link

Add JSON tags for input structs as well #90

Closed farazfazli closed 10 months ago

farazfazli commented 10 months ago

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 commented 10 months ago

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)

farazfazli commented 10 months ago

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

jschaf commented 10 months ago

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

make update-acceptance-test
farazfazli commented 10 months ago

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 commented 10 months ago

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