From d6d0edb7a6d0d09bca470a6d4f4b5d04285feb1a Mon Sep 17 00:00:00 2001 From: Stefan Bleibinhaus <1172032+ExNexu@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:48:32 -0700 Subject: [PATCH] Fixes NPE in <-pgobject --- doc/tips-and-tricks.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/tips-and-tricks.md b/doc/tips-and-tricks.md index 7a51ed6..76bb41c 100644 --- a/doc/tips-and-tricks.md +++ b/doc/tips-and-tricks.md @@ -417,14 +417,12 @@ containing JSON: (.setValue (->json x))))) (defn <-pgobject - "Transform PGobject containing `json` or `jsonb` value to Clojure - data." - [^org.postgresql.util.PGobject v] + "Transform PGobject containing `json` or `jsonb` value to Clojure data." + [^PGobject v] (let [type (.getType v) value (.getValue v)] (if (#{"jsonb" "json"} type) - (when value - (with-meta (<-json value) {:pgtype type})) + (some-> value <-json (with-meta {:pgtype type})) value))) ```