Fixes NPE in <-pgobject

This commit is contained in:
Stefan Bleibinhaus 2024-07-25 15:48:32 -07:00 committed by GitHub
parent 005ec2ac83
commit d6d0edb7a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -417,14 +417,12 @@ containing JSON:
(.setValue (->json x))))) (.setValue (->json x)))))
(defn <-pgobject (defn <-pgobject
"Transform PGobject containing `json` or `jsonb` value to Clojure "Transform PGobject containing `json` or `jsonb` value to Clojure data."
data." [^PGobject v]
[^org.postgresql.util.PGobject v]
(let [type (.getType v) (let [type (.getType v)
value (.getValue v)] value (.getValue v)]
(if (#{"jsonb" "json"} type) (if (#{"jsonb" "json"} type)
(when value (some-> value <-json (with-meta {:pgtype type}))
(with-meta (<-json value) {:pgtype type}))
value))) value)))
``` ```