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

On Tue, May 3, 2011 at 4:54 PM, Sean Corfield <seancorfi...@gmail.com> wrote:
> Since this thread from October focused on clojure.core/resultset-seq,
> I thought I'd bump it again in the context of the (new)
> clojure.java.jdbc library (formerly clojure.contrib.sql).
>
> In order to support naming strategies, c.j.j uses an internal,
> modified copy of resultset-seq that allows you to control the way SQL
> entity names are converted to keywords. The default is still
> clojure.string/lower-case but you can override the behavior for calls
> to c.j.j. Naming strategies also allow you to control how keywords are
> converted to SQL entity names within c.j.j.
>
> I'm undecided on whether to expose this function (it's currently
> clojure.java.jdbc.internal/resultset-seq*) as part of the public API
> for c.j.j. In favor of exposing it: it would provide a way to get the
> behavior most people in this thread seem to want. Against exposing it:
> potential confusion with the version in clojure.core?
>
> This is the only decision I want to tie up before declaring a 0.0.1
> release of c.j.j (and moving on to other requested enhancements for
> 0.0.2).
>
> If anyone has any input...?
>
> Sean
>
> On Fri, Oct 15, 2010 at 2:04 PM, Laurent PETIT <laurent.pe...@gmail.com> 
> wrote:
>>
>>
>> 2010/10/15 Mark Engelberg <mark.engelb...@gmail.com>
>>>
>>> On Fri, Oct 15, 2010 at 1:49 AM, David Powell <djpow...@djpowell.net>
>>> wrote:
>>> > I'm in favour of down-casing - at least by default.  Some processing is
>>> > going to happen anyway, as column names might contain spaces, which 
>>> > wouldn't
>>> > be allowed in keywords.
>>> >
>>> > --
>>> > Dave
>>>
>>> One of the more significant nuisances in Clojure/Java interop is that
>>> if you use some sort of wrapper library which converts Clojure things
>>> to Java, and then converts from Java back to Clojure, you often end up
>>> with something different than you started.  Anywhere we can ameliorate
>>> this, we should.
>>>
>>> For example, if I create a table using clojure.contrib.sql, where the
>>> column names are things like :numberOfApples, and then I load in a
>>> bunch of maps of the form {:numberOfApples 2}, {:numberOfApples 5},
>>> and so on, then when I fetch them out of the database, I really need
>>> them to be {:numberOfApples 2}, etc. so that I can compare them with
>>> the original maps used to fill the database to begin with.
>>>
>>> Right now, I get back {:numberofapples 2}.  Yes, SQL is usually case
>>> insensitive, but Clojure is not, so everything breaks down if you
>>> don't get back the maps in the form you started with.  Since SQL
>>> typically *stores* the column names internally in mixed case (even
>>> though it ignores the case for querying purposes), you might as well
>>> retrieve them in mixed case so it matches the form you started with.
>>>
>>> Why would I write my column names using mixed case?  Because I once
>>> tried using :number-of-apples to match Clojure's conventions, but got
>>> burned by a number of third-party tools gagging on the hyphens.
>>>
>>
>> I guess most of the time column names are written with
>> names_separated_by_underscores, but anyway, it seems indeed weird that such
>> downcase is done, especially without any (or to come) good reason for that.
>>
>>
>
> --
> 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

-- 
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