What is the prefered way to realize row from the result of next.jdbc/plan
as is, without any transformation?
Identity doesn't work:
(require '[next.jdbc :as jdbc])
(def sql-params
["SELECT column1
FROM (VALUES (1, 1, 1),
(2, 2, 2),
(3, 3, 3)) AS _"])
(into []
(map identity)
(jdbc/plan db-spec
sql-params))
;=> [{row} from `plan` -- missing `map` or `reduce`?
; {row} from `plan` -- missing `map` or `reduce`?
; {row} from `plan` -- missing `map` or `reduce`?]
If rows are represented as maps (default), #(into {} %)
works:
(into []
(map #(into {} %))
(jdbc/plan db-spec
sql-params))
;=> [{:column1 1} {:column1 2} {:column1 3}]
If rows are represented as vectors (builder-fn
), vec
can be used:
(require '[next.jdbc.result-set :as rs])
(into []
(map vec)
(jdbc/plan db-spec
sql-params
{:builder-fn rs/as-arrays}))
;=> [[1] [2] [3]]
Is there any xform that would cover both map and vector row realization?
Or should I use something other than plan
for lazy result set reading?