gregbell/active_admin — Issue #971: Bug: Invalid SQL when sorting tables with a column named "group"
Author: ggilder
Created: 2012-02-03 21:36:00+00:00
State: open

If I use ActiveAdmin to manage a model with a field named "group", and I include that field as a column in the index, then clicking on the column header to sort by group produces the following error:

```
SQLite3::SQLException: near "group": syntax error: SELECT "mymodel".* FROM "mymodel" ORDER BY "mymodel".group desc LIMIT 30 OFFSET 0
```

It looks to me like the column name should be quoted as well - I traced this down to `lib/active_admin/resource_controller/collection.rb`, line 53 as of commit 813c86b000. It works correctly for me if I change that line to:

```ruby
table_column = (column =~ /\./) ? column : "#{table}.`#{column}`"
```

But I'm getting a hard Ruby crash trying to run the test suite, so I'm not able to see what other things that might affect.

Thoughts?

-Gabriel