In Opaleye, how to insert to two tables in the same query?

90 views Asked by At

My database has two tables with bijective row correspondence (as described in this question). It seems this means that to insert a row to each table without violating foreign key constraints requires the two inserts to occur within the same query.

In the Opaleye.Manipulation module I see functions such as runInsertMany, which insert into a single table. However, these return an IO action and not a query, and I do not see how to combine them into one. Nowhere in Opaleye do I see how to insert into two tables, or an insert Query possible of combining with another.

Can Opaleye insert into two different tables within the same query? How?

1

There are 1 answers

0
Tom Ellis On BEST ANSWER

Can Opaleye insert into two different tables within the same query?

No, it can't. I didn't even know that was possible! If you email me (my contact details are in the README) then we can discuss your use case.