File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 1
1
(ns xt-play.transactions
2
2
(:require [clojure.string :as str]
3
- [clojure.data.json :as json ]
3
+ [jsonista.core :as j ]
4
4
[clojure.instant :refer [read-instant-date]]
5
5
[clojure.tools.logging :as log]
6
6
[xt-play.util :as util]
33
33
(defn format-system-time [s]
34
34
(when s (read-instant-date s)))
35
35
36
- (defn- PGobject->clj [v]
37
- (if (= org.postgresql.util.PGobject (type v))
38
- (json/read-str (.getValue v) :key-fn keyword)
39
- v))
36
+ (defn- PG->clj [v]
37
+ (cond
38
+ (instance? org.postgresql.util.PGobject v) (-> (.getValue v)
39
+ (j/write-value-as-bytes j/default-object-mapper)
40
+ (j/read-value j/default-object-mapper))
41
+ (instance? org.postgresql.jdbc.PgArray v) (->> (.getArray v)
42
+ (into [])
43
+ (str/join " ," )
44
+ (format " [%s]" ))
45
+ :else v))
40
46
41
47
(defn- parse-result [result]
42
48
; ; TODO - this shouldn't be needed, a fix is on the way in
43
49
; ; a later version of xtdb-jdb
44
- ; ; This will only pick up top level objects
50
+ ; ; This should do it for now - get decent string representation so it looks more like psql output
45
51
(mapv
46
52
(fn [row]
47
- (mapv PGobject ->clj row))
53
+ (mapv PG ->clj row))
48
54
result))
49
55
50
56
(defn- run!-tx [node tx-type tx-batches query]
68
74
(xtdb/jdbc-execute! conn statement))
69
75
(log/info " beta running query:" query)
70
76
(let [res (xtdb/jdbc-execute! conn [query])]
71
- (log/info " beta query resoponse " res)
77
+ (log/info " beta query response " res)
72
78
(parse-result res)))))
73
79
74
80
(defn run!!
Original file line number Diff line number Diff line change 73
73
(pr-str value)]
74
74
; ; default
75
75
[hl/code {:language " json" }
76
- (js/JSON.stringify ( clj->js value) )])]))]))]]))
76
+ (str value)])]))]))]]))
77
77
78
78
(defn- title [& body]
79
79
(into [:h2 {:class " text-lg font-semibold" }]
You can’t perform that action at this time.
0 commit comments