jschaf / pggen

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

Querier only has the methods from the Leader file #20

Closed abijr closed 3 years ago

abijr commented 3 years ago

Querier interface only has the methods generated from the Leader file.

Example: https://gist.github.com/abijr/ea58ff718b99a830c79772c803b86743

You can see that only the QueryOne methods are added to the Querier interface, QueryTwo is ignored: https://gist.github.com/abijr/ea58ff718b99a830c79772c803b86743#file-one-sql-go-L17-L24

I expected it to include all the queries from all the generated files.

I think that the problem is that only the queries that correspond to a single file are stored the TemplatedFile struct. Not sure how you would like to approach the fix.

jschaf commented 3 years ago

Thanks for the detailed bug report. I've verified that it's definitely broken with:

pggen gen go --query-glob 'one.sql' --query-glob 'two.sql'

I have a few ideas for fixes. I'll likely need some sort of package struct.

jschaf commented 3 years ago

You should be good to go with e7b20e4. The new release at https://github.com/jschaf/pggen/releases/tag/2021-03-25 has the fix.

landbed commented 3 years ago

@jschaf This issue seems still happen.

tag: https://github.com/jschaf/pggen/tree/2021-04-20

landbed commented 3 years ago

oops, just ignore that comment. It works, go get -u can not upgrade the binary. Could u pls add a tag or version to command line outputs?

jschaf commented 3 years ago

Yea, I'm not sure how to give install instructions via go get. Last time I checked, the Go authors don't seem particularly eager to become a binary distribution mechanism.