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 =
Query.select Expr.[no; name] ~from:accounts
|> Request.make_many
|> Petrol.collect_list db
|> Lwt_result.map (List.map (fun (id, (text, ())) ->
(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.
Thanks.