From c027de25929f1dfe3820a1b86358dec9c5e8be61 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 1 Nov 2022 09:41:39 +0100 Subject: [PATCH] :sparkles: Make nil safe some decode helpers on db ns --- backend/src/app/db.clj | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/backend/src/app/db.clj b/backend/src/app/db.clj index 773958039..e62b8290b 100644 --- a/backend/src/app/db.clj +++ b/backend/src/app/db.clj @@ -420,21 +420,23 @@ (defn decode-json-pgobject [^PGobject o] - (let [typ (.getType o) - val (.getValue o)] - (if (or (= typ "json") - (= typ "jsonb")) - (json/read val) - val))) + (when o + (let [typ (.getType o) + val (.getValue o)] + (if (or (= typ "json") + (= typ "jsonb")) + (json/read val) + val)))) (defn decode-transit-pgobject [^PGobject o] - (let [typ (.getType o) - val (.getValue o)] - (if (or (= typ "json") - (= typ "jsonb")) - (t/decode-str val) - val))) + (when o + (let [typ (.getType o) + val (.getValue o)] + (if (or (= typ "json") + (= typ "jsonb")) + (t/decode-str val) + val)))) (defn inet [ip-addr]