You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If sqlc were to support generating QueryRewriter compatible interfaces (using an opt-in config variable to preserve backwards compatibility) it would open up more possibilities besides just support for pgxmock.
The actual PostgreSQL $1 style placeholders are not bad when there are only a few. But it rapidly gets difficult to manage when there are a lot of them especially when certain arguments are used multiple times.
I propose adding QueryRewriter interface defined as something like:
If a QueryRewriter was the first argument to a query its RewriteQuery method would be called and the query would run on the results.
This would provide a means to add a type NamedArgs map[string]any that implements named arguments via QueryRewriter. In this way named arguments could be added fairly seamlessly.
In addition, QueryRewriter might be useful for several other utilities. e.g. an InsertArgs that is used to create the column list and the values clause of an insert statement. Not sure if anything past NamedArgs would be useful or a good idea but the flexibility of this approach would enable all sorts of experiments like that without needing to put them in pgx.
What do you want to change?
The
Querier
interface currently looks like:When using
pgx/v5
, the generated code could instead use itsQueryRewriter
interface.That would enable compatibility with other libraries which support
QueryRewriter
, such as pgxmock.Params
could then be used as its mock args.What database engines need to be changed?
PostgreSQL
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: