diff --git a/src/next/jdbc/result_set.clj b/src/next/jdbc/result_set.clj index 047edbf..a9fbac5 100644 --- a/src/next/jdbc/result_set.clj +++ b/src/next/jdbc/result_set.clj @@ -373,13 +373,13 @@ (catch Throwable _ "{row} from `plan` -- missing `map` or `reduce`?")))))) -(defmethod print-dup MapifiedResultSet [_ ^java.io.Writer w] - (.write w "{row} from `plan` -- missing `map` or `reduce`?")) +(defmethod print-dup MapifiedResultSet [rs ^java.io.Writer w] + (.write w (str rs))) (prefer-method print-dup MapifiedResultSet clojure.lang.IPersistentMap) -(defmethod print-method MapifiedResultSet [_ ^java.io.Writer w] - (.write w "{row} from `plan` -- missing `map` or `reduce`?")) +(defmethod print-method MapifiedResultSet [rs ^java.io.Writer w] + (.write w (str rs))) (prefer-method print-method MapifiedResultSet clojure.lang.IPersistentMap) diff --git a/test/next/jdbc_test.clj b/test/next/jdbc_test.clj index 7c456d6..e90322a 100644 --- a/test/next/jdbc_test.clj +++ b/test/next/jdbc_test.clj @@ -165,7 +165,15 @@ VALUES ('Pear', 'green', 49, 47) (is (re-find #"missing reduction" s))) (let [s (pr-str (into [] (jdbc/plan (ds) ["select * from fruit"])))] (is (re-find #"missing `map` or `reduce`" s))) + ;; this may succeed or not, depending on how the driver handles things + ;; most drivers will error because the ResultSet was closed before pr-str + ;; is invoked (which will attempt to print each row) (let [s (pr-str (into [] (take 3) (jdbc/plan (ds) ["select * from fruit"])))] - (is (re-find #"missing `map` or `reduce`" s))) + (is (or (re-find #"missing `map` or `reduce`" s) + (re-find #"(?i)^\[#:fruit\{.*:id.*\}\]$" s)))) + (is (every? #(re-find #"(?i)^#:fruit\{.*:id.*\}$" %) + (into [] (map str) (jdbc/plan (ds) ["select * from fruit"])))) + (is (every? #(re-find #"(?i)^#:fruit\{.*:id.*\}$" %) + (into [] (map pr-str) (jdbc/plan (ds) ["select * from fruit"])))) (is (thrown? IllegalArgumentException (doall (take 3 (jdbc/plan (ds) ["select * from fruit"]))))))