Closed marcosh closed 2 years ago
Your best option is probably going to be using catListTable
to convert a ListTable
to a Query
of all of its rows, and then using exists
to test if the given row is in the list. This won't quite be the type you want, as this will pull you into the Query
monad. I'd also warn that this is likely to have quite poor performance (I doubt PostgreSQL will be able to use an index, for example), but I may be wrong!
Thanks @ocharles for the answer.
I hoped there would be a way without ending in the Query
monad
Unfortunately it will probably be quite difficult, due to what ListTable
actual means in terms of a query. If you have a table T
with n columns, then a ListTable T
is a table with n columns, but each column is a PostgreSQL array. To see if a row is in a list table means you have to check each of these n arrays contains the respective column from the row you're looking up and that all elements have the same index. It's certainly doable, but I'm not sure it can be done with the Rel8 API at the moment.
I see, thanks for the clarification. For the moment I'm doing it at the Haskell level instead of at the database level. Not super performant, but it makes things easier at least
I would like to have a function with the following signature
which checks whether the second argument is contained in the list table.
Is this something which is achievable with the provided API? How could I do that?