jschaf / pggen

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

void return value not recognized #11

Closed aight8 closed 3 years ago

aight8 commented 3 years ago
ERROR: generate go code: template all: template query file xxx no go type found for Postgres type void oid=2278

I try to call a function without a return value

-- name: Something :exec
select * something(pggen.arg('arg1'), pggen.arg('arg2'), pggen.arg('arg3'));

-- or

-- name: Something :exec
select something(pggen.arg('arg1'), pggen.arg('arg2'), pggen.arg('arg3'));

workaround:

-- name: Something :exec
select true from something(pggen.arg('arg1'), pggen.arg('arg2'), pggen.arg('arg3'));
jschaf commented 3 years ago

Yep, definitely a bug. I'll take a look. The main difficulty is likely figuring out what Go type pgx wants to use to decode void types. I think I can use nil anything and pgx will skip the column.

jschaf commented 3 years ago

Should be fixed by https://github.com/jschaf/pggen/commit/a12d23ed4510ebcfcd935addb3909202b0368b31. Let me know if that doesn't do the trick.