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]
(let [typ (.getType o) (when o
val (.getValue o)] (let [typ (.getType o)
(if (or (= typ "json") val (.getValue o)]
(= typ "jsonb")) (if (or (= typ "json")
(json/read val) (= typ "jsonb"))
val))) (json/read val)
val))))
(defn decode-transit-pgobject (defn decode-transit-pgobject
[^PGobject o] [^PGobject o]
(let [typ (.getType o) (when o
val (.getValue o)] (let [typ (.getType o)
(if (or (= typ "json") val (.getValue o)]
(= typ "jsonb")) (if (or (= typ "json")
(t/decode-str val) (= typ "jsonb"))
val))) (t/decode-str val)
val))))
(defn inet (defn inet
[ip-addr] [ip-addr]