ernie/squeel — Issue #90: Ordering by generated column
Author: the8472
Created: 2012-01-02 14:13:06+00:00
State: open

```
Vacancy.select{count(id).as("vac_count")}.order{vac_count.desc}
```
generates thw following SQL:

```
SELECT count("vacancies"."id") AS vac_count FROM "vacancies" ORDER BY "vacancies"."vac_count" DESC
```

which in turn results in the following error:

`ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: vacancies.vac_count`

the correct SQL would be:
`SELECT count("vacancies"."id") AS vac_count FROM "vacancies" ORDER BY "vac_count" DESC`

Using a string in the order by clause works of course, but that way I can't use the DSL (i.e. the .desc/.asc)