karamaan/karamaan-opaleye — pull request #60 by hesselink (2014-08-11 20:30:42+00:00)
Title: Implement orderBy.

I've implemented `orderBy`, roughly according to `TODO.md`. I had to use an actual `Scope`, not an empty one, since the columns need to be looked up there. This also required a `Default (PPOfContraVariant Unpackspec)` instance. Would you also want the non-default versions?

I've also changed the API a little bit. The `Query` argument seemed redundant, it just required duplicating the `Category` composition. Also, `makeOrderSpec` seemed a bit verbose, I went with `asc` and `desc` instead. Feel free to suggest other names, or point out any changes you'd like regarding coding style and such, since I'm not sure exactly what you use.

I haven't thoroughly tested this, but examples like this work:

``` haskell
orderedPersons = orderBy [desc (2 * arr age), asc (arr address)] . personTable
```

This produces the following SQL:
``` sql
SELECT name as name_1,
age as age_1,
address as address_1
FROM persons as T1
```