LauJensen / clojureql

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

Join ordering fails with table aliases #95

Closed paraseba closed 12 years ago

paraseba commented 13 years ago

If you alias tables (as in (table {:users :u})) joins are not ordered according to table dependencies. It's a serious problem, since you can't reorder them manually, so it fails on execution.

I created a test case showing the problem here

https://github.com/paraseba/clojureql/commit/2e330a10b19d33cdde53868f7a8fa155e974658d

The first test case, without alias passes, the second, with table aliases fails.

I think the problem is the algorithm is using stringified column names to make a set difference. In case of alias, the string take the form "name alias" in table names, but not in column dependency vectors.

mccraigmccraig commented 12 years ago

this pull request fixes this bug and adds some tests :

https://github.com/LauJensen/clojureql/pull/112

bendlas commented 12 years ago

I've pulled McCraig's fix. Can you verify that it fixes the bug?

LauJensen commented 12 years ago

It seems fixed to me. If you still see a problem Parseba, please reopen and make sure to include both the generated sql and the expected sql. Thanks!