Trying to use Petrol for db access

Hello -

Newbie in OCaml here. I am trying to use Petrol (GitHub - Gopiandcode/petrol: Petrol's an OCaml SQL API made to go FAST.) for Postgres access. I have gone through the examples in the documentation at index (petrol.index).

I get the basics of the APIs. But I am not able to find any examples on how to deal with nullable columns in query. e.g.

In the snippet

let collect_all db = Expr.[no; name] ~from:accounts
    |> Request.make_many
    |> Petrol.collect_list db
    |> ( (fun (id, (text, ())) ->

how do I handle the case if the returned name column is nullable. I would like to check within the map function if text is null. Looks like it’s still returned as a string.

Any help will be appreciated.


Looks like there is an open pull request to add nullable types functionality. No response yet. You could try using the fork.