Fork me on GitHub
#sql
<
2017-10-05
>
jonas07:10:12

I know I’ve struggled with this before, but is there a way to get clojure.java.jdbc/query to return a sequence of string keyed maps? With {:identifiers identity} I still get keywords

seancorfield15:10:19

@jonas No, it always produces keyword-keyed maps. What’s your use case?

jonas17:10:28

@seancorfield I’ve got some other (string) data from elsewhere in the system, so it would be natural to work with string keys in this particular case. It’s also possible for quoted column names to not map well to keywords. i.e., (jdbc/query db "SELECT 1 as \"a column\"") is perfectly valid sql

jonas17:10:42

Sometimes (perhaps not often) string keys just make more sense. For example you can opt out of keyword keys in most json parsers (for example cheshire)

noisesmith17:10:12

@jonas of course clojure doesn’t complain about putting any old garbage in a keyword as long as you aren’t trying to get it via a reader

noisesmith17:10:28

but yeah, that seems like a reasonable thing to want to do absolutely

seancorfield17:10:46

@jonas Do you want to create a JIRA issue for this and I can take a look?

jonas18:10:12

I could dig into the source as well and try to provide a patch. Or do you want to think about if we even want/need this first?

seancorfield18:10:20

I'll need to give it some thought, as regards the right option naming.

seancorfield18:10:06

My initial reaction is :keywordize? which will default to true for backward compatibility and I believe is common among JSON libraries?

noisesmith18:10:57

this is happy news to me 😄

jonas18:10:08

:keywordize? true makes sense. Ping me if you want a patch at some point

ikitommi20:10:09

@seancorfield would you be interested in a initial perf test suite for clojure.java.jdbc?

ikitommi20:10:58

(and some perf patches later if they have any real effect)

seancorfield20:10:27

Regarding the specs or in general?

seancorfield20:10:26

(either way I'm interested in performance improvements for it)