jschaf / pggen

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

Support for psql-like parameters (:parameter) #42

Closed ghost closed 2 years ago

ghost commented 3 years ago

In order for the .sql files to be tested by a regression tool, e.g. regresql, it would be nice, if the psql-like parameters could be supported.

So, the following SQL statements should be equal:

-- name: CurrentVersion :one
select name from albums where id = pggen.arg('id');

-- name: NewVersion :one
select name from albums where id = :id;
jschaf commented 2 years ago

One of the goals I'm shooting for with pggen is to limit the number of knobs and being okay with using another tool for tweaks like this. I'll keep pggen with a single input syntax for now.

For your use case, using sed would probably work, though admittedly less convenient than if it was built into pggen.