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

inconsistent return structures generated #79

Open bweston92 opened 1 year ago

bweston92 commented 1 year ago
-- name: FindCollectionsWithAssignee :many
select *
from collections
where assignee = pggen.arg('assignee')
order by created
limit pggen.arg('start') offset pggen.arg('limit');

-- name: FindCollectionWithIdentifier :one
select * from collections where collection_id = pggen.arg('collectionID');

produces:

type FindCollectionWithIdentifierRow struct {
...
    Version      int              `json:"version"`
...
}

type FindCollectionsWithAssigneeRow struct {
...
    Version      *int             `json:"version"`
...

Even if I make them both return :one it still makes the Version member on one of them a pointer when they're referencing the same table and column. I've tried removing everything after the where including the order by and limit and still a inconsistent

jschaf commented 1 year ago

Thanks for reporting. Definitely looks like a bug. Probably similar to https://github.com/jschaf/pggen/pull/77. Couple of requests to speed up the fix:

  1. What was the pggen command line you used, specifically the --go-type flags?
  2. Can you provide a minimal schema that reproduces the issue?
  3. What's the output of pggen version?