Skip to content

Commit

Permalink
Merge pull request #284 from ExNexu/patch-1
Browse files Browse the repository at this point in the history
Fix NPE in <-pgobject
  • Loading branch information
seancorfield authored Jul 26, 2024
2 parents 005ec2a + d6d0edb commit 1fed35a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions doc/tips-and-tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
```

Expand Down

0 comments on commit 1fed35a

Please sign in to comment.