bigpresh/Dancer-Plugin-Database — Issue #20: Support for order by / limit clauses in quick_select()
Author: bigpresh
Created: 2012-01-26 15:46:37+00:00
State: open
Labels: wishlist

@bor on IRC requested support for "order by" clauses in the `quick_select` convenience method.

I think the cleanest way to handle this is to repurpose the optional 3rd arg to quick_select() to be a hashref of options (but still supporting the current documented usage of an arrayref of column names), so you could say e.g.:

`database->quick_select('people', { gender => 'male' }, { order_by => 'age' });`

I think it would make sense to roughly follow SQL::Abstract's approach to this:

https://metacpan.org/module/SQL::Abstract#ORDER-BY-CLAUSES

So, you could say `sort_by => 'age'`, `sort_by => [ qw(age height)]`, `sort_by => { desc => age }`, etc.

Passing an arrayref of column names as the 3rd arg would still be accepted for backwards compatibility, but the new documented way would be to pass a hashref containing a `columns` option, e.g.:

`database->quick_select('people', { gender => 'male' }, { columns => [ qw(name email)] });`