On 3/05/2011 23:58, Allen Johnson wrote:
IMHO c.j.j/resultset-seq should perform something like the following:
;; i want my columns as strings exactly how they are in the db
(resultset-seq rs)
(resultset-seq rs identity)
;; i want my columns as lower-case keywords
(resultset-seq rs (comp keyword lower-case))
;; i want my columns as upper-case symbols
(resultset-seq rs (comp symbol upper-case))
With the existing c.c/resultset-seq, I found myself converting the
keys back to strings in order to pass those results to some existing
Java code and templates for further processing. Most of the time the
lower-cased keyword keys were just fine.
Just my $0.02
Allen
It would definitely be a plus to have some facilities for conversion
from/to clojure coding standard.
Not only for result sets but also for update functions and so on.
I personally would prefer this as a default :
customer_id -> :customer-id (and the reverse)
In a perfect world, it indeed would be best to have some control over
this. Maybe add this context as parameters to the connection object ?
(with-connection {:classname "org.postgresql.driver"
:subprotocol "postgresql"
:subname (str "//" db-host ":" db-port "/" db-name)
:user user
:password password
:field-names {:from-sql pascal-case->clojure ; or something
like this : (field-name-converter-fn :underscores :clojure-keyword)
:to-sql clojure->pascal-case}}
(do-stuff))
field-name-converter-fn being a multi-method returning a lambda that
does the conversion. One would be able to add his own methods, or simply
use the identity function.
Sacha
--
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