Make nil safe some decode helpers on db ns

This commit is contained in:
Andrey Antukh 2022-11-01 09:41:39 +01:00 committed by Andrés Moya
parent ce99ca0aa8
commit c027de2592

View file

@ -420,21 +420,23 @@
(defn decode-json-pgobject (defn decode-json-pgobject
[^PGobject o] [^PGobject o]
(when o
(let [typ (.getType o) (let [typ (.getType o)
val (.getValue o)] val (.getValue o)]
(if (or (= typ "json") (if (or (= typ "json")
(= typ "jsonb")) (= typ "jsonb"))
(json/read val) (json/read val)
val))) val))))
(defn decode-transit-pgobject (defn decode-transit-pgobject
[^PGobject o] [^PGobject o]
(when o
(let [typ (.getType o) (let [typ (.getType o)
val (.getValue o)] val (.getValue o)]
(if (or (= typ "json") (if (or (= typ "json")
(= typ "jsonb")) (= typ "jsonb"))
(t/decode-str val) (t/decode-str val)
val))) val))))
(defn inet (defn inet
[ip-addr] [ip-addr]