Fixes #130 by implementing lookup on the adapters
This commit is contained in:
parent
71ea50eff8
commit
65296ee4ad
4 changed files with 39 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
|||
Only accretive/fixative changes will be made from now on.
|
||||
|
||||
Changes made on **develop** since the 1.1.547 release:
|
||||
* Fix #130 by implementing `clojure.lang.ILookup` on the three builder adapters.
|
||||
* Correct MySQL batch statement rewrite tip: it's `:rewriteBatchedStatements true` (plural). Also surface the batch statement tips in the **Tips & Tricks** page.
|
||||
* Clarify how combining is interleaving with reducing in **Reducing and Folding with `plan`**.
|
||||
* Use "JDBC URL" consistently everywhere (instead of "JDBC URI" in several places).
|
||||
|
|
|
|||
|
|
@ -125,4 +125,7 @@
|
|||
rs/ResultSetBuilder
|
||||
(->rs [this] (rs/->rs mrsb))
|
||||
(with-row [this mrs row] (rs/with-row mrsb mrs row))
|
||||
(rs! [this mrs] (rs/rs! mrsb mrs))))))
|
||||
(rs! [this mrs] (rs/rs! mrsb mrs))
|
||||
clojure.lang.ILookup
|
||||
(valAt [this k] (get mrsb k))
|
||||
(valAt [this k not-found] (get mrsb k not-found))))))
|
||||
|
|
|
|||
|
|
@ -244,7 +244,10 @@
|
|||
ResultSetBuilder
|
||||
(->rs [this] (->rs mrsb))
|
||||
(with-row [this mrs row] (with-row mrsb mrs row))
|
||||
(rs! [this mrs] (rs! mrsb mrs))))))
|
||||
(rs! [this mrs] (rs! mrsb mrs))
|
||||
clojure.lang.ILookup
|
||||
(valAt [this k] (get mrsb k))
|
||||
(valAt [this k not-found] (get mrsb k not-found))))))
|
||||
|
||||
(defn clob->string
|
||||
"Given a CLOB column value, read it as a string."
|
||||
|
|
@ -360,7 +363,10 @@
|
|||
ResultSetBuilder
|
||||
(->rs [this] (->rs arsb))
|
||||
(with-row [this mrs row] (with-row arsb mrs row))
|
||||
(rs! [this mrs] (rs! arsb mrs))))))
|
||||
(rs! [this mrs] (rs! arsb mrs))
|
||||
clojure.lang.ILookup
|
||||
(valAt [this k] (get arsb k))
|
||||
(valAt [this k not-found] (get arsb k not-found))))))
|
||||
|
||||
(declare navize-row)
|
||||
|
||||
|
|
|
|||
|
|
@ -182,6 +182,32 @@
|
|||
(is (contains? row (column :FRUIT/appearance)))
|
||||
(is (nil? ((column :FRUIT/appearance) row)))
|
||||
(is (= 3 ((column :FRUIT/id) row)))
|
||||
(is (= "Peach" ((column :FRUIT/name) row))))
|
||||
(let [builder (rs/as-maps-adapter
|
||||
rs/as-modified-maps
|
||||
(fn [^ResultSet rs _ ^Integer i]
|
||||
(.getObject rs i)))
|
||||
row (p/-execute-one (ds)
|
||||
["select * from fruit where id = ?" 3]
|
||||
(assoc
|
||||
(default-options)
|
||||
:builder-fn (rs/as-maps-adapter
|
||||
builder
|
||||
(fn [^ResultSet rs
|
||||
^ResultSetMetaData rsmeta
|
||||
^Integer i]
|
||||
(condp = (.getColumnType rsmeta i)
|
||||
java.sql.Types/VARCHAR
|
||||
(.getString rs i)
|
||||
java.sql.Types/INTEGER
|
||||
(.getLong rs i)
|
||||
(.getObject rs i))))
|
||||
:label-fn str/lower-case
|
||||
:qualifier-fn identity))]
|
||||
(is (map? row))
|
||||
(is (contains? row (column :FRUIT/appearance)))
|
||||
(is (nil? ((column :FRUIT/appearance) row)))
|
||||
(is (= 3 ((column :FRUIT/id) row)))
|
||||
(is (= "Peach" ((column :FRUIT/name) row))))))
|
||||
|
||||
(deftest test-row-number
|
||||
|
|
|
|||
Loading…
Reference in a new issue