LauJensen / clojureql

ClojureQL is superior SQL integration for Clojure
https://clojureql.sabrecms.com
Eclipse Public License 1.0
285 stars 39 forks source link

Sort with #asc or #desc fails on aliased tables #49

Closed mattdw closed 13 years ago

mattdw commented 13 years ago

Sort when specifying #asc or #desc throws a ClassCastException when run on an aliased table. For example:

user> (-> (table nil :posts) (sort [:published]))
SELECT posts.* FROM posts ORDER BY published asc
user> (-> (table nil :posts) (sort [:published#desc]))
SELECT posts.* FROM posts ORDER BY posts.published desc
user> (-> (table nil {:posts :p1}) (sort [:published#asc]))
java.lang.RuntimeException caused by: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named

Backtrace:

0: clojure.core$name.invoke(core.clj:1245)
1: clojureql.internal$to_orderlist$fn__2339$fn__2340.invoke(internal.clj:70)
2: clojure.core$map$fn__3695.invoke(core.clj:2094)
3: clojure.lang.LazySeq.sval(LazySeq.java:42)
4: clojure.lang.LazySeq.seq(LazySeq.java:56)

(Otherwise greatly enjoying clojureql; nice work!)

LauJensen commented 13 years ago

Hi,

Im glad you're enjoying CQL!

This is from my REPL on MASTER/HEAD:

clojureql.core> (-> (table nil {:posts :p1}) (sort [:published#asc])) SELECT p1.* FROM posts p1 ORDER BY p1.published asc

Could you please retry on the latest code and if there's still a problem, re-open this issue?

Thanks, Lau