default value expression can be arbitrary sql excepting that it must not contain any calls to pggen.arg(...)
select pggen.arg('param', <default value expression>) compiles to select coalesce($1, <default value expression>)
the code generator produces a nullable go type for param so that nil may be passed into the query
technically this supports an arbitrary number of arguments -- eg pggen.arg('param', null::int, 1) would compile to coalesce($1, null::int, 1) -- which doesn't seem particularly useful but neither does it seem harmful enough to add logic to prevent
(sorry for the import reordering ... the vscode go extension does this by default -- not entirely clear to me why vscode go doesn't just comply with whatever the best/agreed upon default formatting conventions are for the ecosystem ... -- happy to update to remove those changes if you want)
Adds support for two arg version of
pggen.arg()
pggen.arg('param', <default value expression>)
pggen.arg(...)
select pggen.arg('param', <default value expression>)
compiles toselect coalesce($1, <default value expression>)
param
so that nil may be passed into the queryCloses https://github.com/jschaf/pggen/issues/86 and https://github.com/jschaf/pggen/issues/85
(sorry for the import reordering ... the vscode go extension does this by default -- not entirely clear to me why vscode go doesn't just comply with whatever the best/agreed upon default formatting conventions are for the ecosystem ... -- happy to update to remove those changes if you want)