mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 09:06:37 +02:00
✨ Improve null handling on more db helpers
This commit is contained in:
parent
d584ae5a0f
commit
d768711caa
1 changed files with 12 additions and 9 deletions
|
@ -442,22 +442,25 @@
|
||||||
|
|
||||||
(defn inet
|
(defn inet
|
||||||
[ip-addr]
|
[ip-addr]
|
||||||
(doto (org.postgresql.util.PGobject.)
|
(when ip-addr
|
||||||
(.setType "inet")
|
(doto (org.postgresql.util.PGobject.)
|
||||||
(.setValue (str ip-addr))))
|
(.setType "inet")
|
||||||
|
(.setValue (str ip-addr)))))
|
||||||
|
|
||||||
(defn decode-inet
|
(defn decode-inet
|
||||||
[^PGobject o]
|
[^PGobject o]
|
||||||
(if (= "inet" (.getType o))
|
(when o
|
||||||
(.getValue o)
|
(if (= "inet" (.getType o))
|
||||||
nil))
|
(.getValue o)
|
||||||
|
nil)))
|
||||||
|
|
||||||
(defn tjson
|
(defn tjson
|
||||||
"Encode as transit json."
|
"Encode as transit json."
|
||||||
[data]
|
[data]
|
||||||
(doto (org.postgresql.util.PGobject.)
|
(when data
|
||||||
(.setType "jsonb")
|
(doto (org.postgresql.util.PGobject.)
|
||||||
(.setValue (t/encode-str data {:type :json-verbose}))))
|
(.setType "jsonb")
|
||||||
|
(.setValue (t/encode-str data {:type :json-verbose})))))
|
||||||
|
|
||||||
(defn json
|
(defn json
|
||||||
"Encode as plain json."
|
"Encode as plain json."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue