pggen icon indicating copy to clipboard operation
pggen copied to clipboard

inconsistent return structures generated

Open bweston92 opened this issue 2 years ago • 1 comments

-- 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

bweston92 avatar Jan 13 '23 13:01 bweston92

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?

jschaf avatar Jan 13 '23 19:01 jschaf