This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-25
Channels
- # announcements (3)
- # aws (6)
- # beginners (143)
- # boot (14)
- # calva (2)
- # cider (1)
- # clara (1)
- # clj-kondo (1)
- # cljdoc (4)
- # cljs-dev (50)
- # cljsrn (5)
- # clojure (61)
- # clojure-chicago (1)
- # clojure-europe (4)
- # clojure-italy (5)
- # clojure-nl (5)
- # clojure-spec (32)
- # clojure-uk (11)
- # clojurescript (166)
- # clojureverse-ops (2)
- # clr (3)
- # core-typed (1)
- # cursive (8)
- # datomic (21)
- # defnpodcast (1)
- # emacs (1)
- # figwheel (1)
- # figwheel-main (1)
- # fulcro (7)
- # graphql (7)
- # jobs (8)
- # leiningen (4)
- # luminus (3)
- # lumo (17)
- # mount (3)
- # nrepl (4)
- # off-topic (113)
- # pedestal (1)
- # re-frame (15)
- # reagent (2)
- # reitit (2)
- # shadow-cljs (75)
- # spacemacs (3)
- # sql (12)
- # tools-deps (44)
- # uncomplicate (2)
- # xtdb (15)
@seancorfield (or others): is there a best-way (simply explained) of turning a DatabaseMetaData
ResultSet
into the appropriate vector of maps? I’m trying to pull a table’s column-metadata in order to turn it into a skeleton GraphQL query, for what that’s worth.
Sounds interesting, a bit like hasura? https://github.com/hasura/graphql-engine
No, more a bit like “gee, I never do anything straightaway, and it would be cool to learn something about GraphQL while I work on this antique Rails app, and since I write all my tools using parentheses anyway…”
@luskwater Have you looked at http://clojure.github.io/java.jdbc/#clojure.java.jdbc/metadata-query (and metadata-result
)?
Came across this, might be interesting, although I have my doubts his useful reactive really is. https://speakerdeck.com/mp911de/reactive-relational-database-connectivity?slide=34
@seancorfield did a quick test with the new :builder-fn
. Normal usage is now bit slower as there is the new extra option passing, but it now allows a cached ->row
function to be used. Some numbers (updated to porsas readme) too.
• few hunded nanos extra to the normal case (4000ns) • using cached compiled mapper is 1500ns
the impl for fast the :builder
looks like:
(defn caching-row-builder
([]
(caching-row-builder (p/qualified-key)))
([key]
(let [cache (HashMap.)] ;; TODO: make bounded
(fn [^ResultSet rs opts]
(let [sql (:next.jdbc/sql-string opts)
->row (or (.get cache sql)
(let [cols (#'p/col-map rs key)
->row (#'p/rs-> nil (map second cols))]
(.put cache sql ->row)
->row))]
(reify
rs/RowBuilder
(->row [_] (->row rs))
(with-column [_ row _] row)
(column-count [_] 0)
(row! [_ row] row)
rs/ResultSetBuilder
(->rs [_] (transient []))
(with-row [_ rs row] (conj! rs row))
(rs! [_ rs] (persistent! rs))))))))
;; define once, contains cache of ResultSet->EDN functions
(def caching-builder (caching-row-builder))
(bench! (jdbc/execute! connection ["SELECT * FROM fruit"] {:builder-fn caching-row-builder}))