pggen
pggen copied to clipboard
Dynamic queries: add support for predicates in WHERE clauses
Use case is to enable queries with dynamic expressions for WHERE clauses, like:
SELECT *
FROM foo
WHERE pggen.predicate('filter_expr')
Sketch:
- Generated Go code takes a
FilterExprfunction that returns(string, error), maybe implementing a generic interface so it's easy to wrap existing Go SQL codegen. - If we implement an interface, we should move it to a different library so folks don't have to depend on the relatively heavyweight dependencies of pggen, namely Docker.
- pggen calls FilterExpr and injects code as-is into the query.