Back
InspectableMapifiedResultSet (clj)
(source)protocol
Protocol for exposing aspects of the (current) result set via functions.
The intent here is to expose information that is associated with either
the (current row of the) result set or the result set metadata, via
functions that can be called inside a reducing function being used over
`next.jdbc/plan`, including situations where the reducing function has
to realize a row by calling `datafiable-row` but still wants to call
these functions on the (realized) row.
Examples
next-jdbc
What's left to be tested:
* ReadableColumn protocol extension point"
(:require [clojure.core.protocols :as core-p]
[clojure.datafy :as d]
[clojure.string :as str]
[clojure.test :refer [deftest is testing use-fixtures]]
[next.jdbc.protocols :as p]
[next.jdbc.result-set :as rs]
[next.jdbc.specs :as specs]
[next.jdbc.test-fixtures :refer [with-test-db ds column
default-options
derby? mssql? mysql? postgres?]])
(:import (java.sql ResultSet ResultSetMetaData)))
(deftest test-over-partition-all
;; this verifies that InspectableMapifiedResultSet survives partition-all
(testing "row-numbers on partitioned rows"
(is (= [[1 2] [3 4]]
(into [] (comp (map #(rs/datafiable-row % (ds) %))
(partition-all 2)
(map #(map rs/row-number %)))
(p/-execute (ds) ["select * from fruit"]
(cond-> {:builder-fn rs/as-arrays}
(derby?)
(assoc :concurrency :read-only
:cursors :close
:result-type :scroll-insensitive))))))))