Urso
pgvx: complex return types
You can always return a Datum if you find automatic conversion too limiting. If you want nullable you can return
?Datum
. In that case a null
will be correctly translated into a Datum. When implementing a function with pgzx we use compile time reflection for primitive types via pgzx.datum.findConv
. The findConv function also checks if your type implements fromNullableDatum
and toNullableDatum
(although the check could be more exhaustive and allow more type patterns in the future).
An example from this blog post: https://xata.io/blog/pgzx-update-0.2.0
2 replies