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

bug: whitespace between bracket and argument returns in error #34

Closed ghost closed 3 years ago

ghost commented 3 years ago

This query works:

-- name: FindAllArticles :many
select * from articles where name = pggen.arg('Name')

This one, generated by our formatter with the default settings, does not work (notice the space between arg and ()

-- name: FindAllArticles :many
select * from articles where name = pggen.arg ('Name')

I think, this is related to this line, although I am not sure. https://github.com/jschaf/pggen/blob/44c162198f6e49750389d9b0befbc66d741ac6da/internal/parser/parser.go#L222

And btw, thanks for this project, I love it! 💜

jschaf commented 3 years ago

Thanks for reporting! I added hardcoded support for 1 space after pggen.arg. The correct approach is to use an expression parser, but the hardcoded matching logic is probably good enough.