bogdan/datagrid — pull request #77 by cgag (2013-09-04 21:35:59+00:00)
Title: Fix calls to order_unsupported.

Hey Bogdan, I ran into some issues while trying to provide a custom ordering for a column. It turns out the rails reverse_order method on relations is broken if the you call it on an ordering that uses SQL functions or certain features of postgres (https://github.com/rails/rails/pull/8741, https://github.com/rails/rails/pull/8225, https://github.com/rails/rails/pull/2234, etc). For example if you did:

```Ruby
column "Fake Column", order: "COALESE(A, B)"
```
It would generate the SQL "SELECT... ORDER BY COALESE(A DESC, B);", instead of "SELECT... ORDER BY COALESE(A, B) DESC". This is Rails' fault, but it might be worth documenting.

I eventually got around this by manually specifying order_desc: "COALESE(A,B) DESC", but before I came up with that solution, I was looking at using a proc and I ran into strange errors because driver.reverse_order isn't implemented for active_record. I think it probably should be, but I'm not sure exactly what it should look like. I also found that you were missing the "name" argument to a few order_unsupported calls. I'm not sure what exactly the names should be, but you can see my fix in this pull request. I also noticed that it's an option to have this proc take the relation as an argument, but it appears to be undocumented/tested.

Let me know if any of this doesn't make sense and I can try to explain it better.