[JDBC-41] How to preserve order of rows? Created: 24/Dec/12 Updated: 07/Apr/13 Resolved: 07/Apr/13
I'd like to get the ordered record set within with-query-results
|Comment by Sean Corfield [ 24/Dec/12 12:49 PM ]|
I assume you mean the order of columns within the rows, not the actual order of rows within the result set?
I'm looking at providing an alternative result set format using arrays instead of maps which will preserve column orders.
Since maps are unordered by default in Clojure, I'd be suspicious of code that relies on ordering of keys (so I'm reducing this to 'minor').
|Comment by Konstantin [ 24/Dec/12 10:54 PM ]|
You are right, I mean the order of columns, not the rows.
I understand, that maps are unordered. There are few reasons when
Probably it would be better to do this possibility optional,
|Comment by Sean Corfield [ 25/Dec/12 8:26 PM ]|
An optional keyword argument sounds like a reasonable compromise. I'm already looking at keyword arguments on resultset-seq for returning arrays instead of maps and returning an order-preserving map should be as simple as replacing (zipmap keys (row-values)) with (apply array-map (interleave keys (row-values)))
|Comment by Sean Corfield [ 07/Apr/13 3:38 AM ]|
Fixed in 0.3.0-SNAPSHOT by allowing :as-arrays argument to query and result-set-seq functions, which returns result as vector of column names, followed by vectors for each row.