ppx_rapper icon indicating copy to clipboard operation
ppx_rapper copied to clipboard

Support a list of tuples as input parameters.

Open tcoopman opened this issue 4 years ago • 1 comments

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)

tcoopman avatar Feb 16 '20 08:02 tcoopman

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)).

joprice avatar Jan 28 '24 21:01 joprice