pggen icon indicating copy to clipboard operation
pggen copied to clipboard

Dynamic queries: add support for predicates in WHERE clauses

Open jschaf opened this issue 4 years ago • 0 comments

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 FilterExpr function 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.

jschaf avatar Sep 20 '21 18:09 jschaf