ppx_rapper
ppx_rapper copied to clipboard
Support a list of tuples as input parameters.
I'd like to be able to write a query like this:
WITH foo(a, b) AS (values (1::int, 'a'::text), (2, 'b') ) SELECT * FROM foo;
that could translate to:
[%rapper
get_many
{sql|
WITH foo(a, b) AS (values %list{%tup2{int, string}}) ...
|sql}]
The tup2
, tup3
, ... is not supported at this time though and although you can create a custom type with a tuple they generate only one parameter, so as an input type it doesn't work.
(as discussed on discord)
This can also be useful for queries fetching a list from a table with a compound key like where (x, y) in values ((x1, y1), (x2, y2))
.