Hi all,

I'm not too happy with how resultset-seq down-cases column names and
turns them into keywords, as I would prefer to work with string keys
in some cases.  I came up with the following change to give the caller
a choice to remap column keys in any way.  This leaves resultset-seq's
behavior for a single argument exactly as it was before.

;; Instead of:
user> (resultset-seq rs)
({:empid 3} {:empid 4} ...)

;; We can do this:
user> (resultset-seq rs identity) ;; or any remapping fn
({"empId" 3} {"empId" 4} ...)

I'd love to see the change made to core.  If not, I hope this helps
others who have had the same problem:

https://gist.github.com/723583

And though I'm not thrilled with this, for coping with contrib.sql's
with-query-results macro (which uses resultset-seq) I have the
following:

(defmacro with-query-results2
  "Like clojure.contrib.sql/with-query-results, but returns structmaps
with
String keys identical to those in the ResultSet.  This is done by
dynamically
rebinding clojure.core/resultset-seq to a new function, so take care
if using
that function within body."
  [results sql-params & body]
  `(binding [resultset-seq #(resultset-seq2 % identity)]
     (with-query-results ~results ~sql-params ~...@body)))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to