Closed mudrz closed 1 year ago
this was answered in discuss.ocaml https://discuss.ocaml.org/t/ppx-rapper-join-2-tables-and-return-a-list/11277/2?u=mudrz
type t = {
a_id: int;
a_name: string;
b_id: int;
b_name: string;
}
[%rapper
get_many
{sql|
SELECT
a.id as @int{a_id},
a.name as @string{a_name},
b.id as @int{b_id},
b.name as @string{b_name}
FROM public.table1 as a
INNER JOIN public.table2 as b
ON a.b_id = b.id
WHERE
a.id IN (%list{%string{ids}})
|sql} record_out]
I have 2 tables, with an
id
column and want to join them and return the results:this works, but it results in a tuple, which is not great
(int * string * int * string) list
record_out
doesn't work, becauseid
is the same in both tables:function_out
doesn't work, because I getNot sure where this is coming from? I noticed that not using
%list
compiles the ppx (WHERE a.id = %string{id}
) (but doesn't work for my use case)Is it possible to use
%list
andfunction_out
somehow?