Improve printability as part of #51
Since `str` may be able to realize a row and render it as a string, attempts to print a row use this route to circumvent `print-sequential` failing due to lazy evaluation.
This commit is contained in:
parent
0fd8bf1a88
commit
e0b0c214fd
2 changed files with 13 additions and 5 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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"]))))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue