[Dbix-class] quote char works with sorting without breaking too much!

Jess Robinson castaway at desert-island.demon.co.uk
Wed Jun 21 11:08:09 CEST 2006


Ah, but this has fun with functions, which are currently supported as:

order_by => [ { 'count' => '*'} ] .. etc

At the last discussion of this, my end proposal was the following:

  order by => [ [ 'name', 'asc'], 'lastname', [ { sum => 'age' }, 'desc' ] ]

That is, the items in order by can be either:
1) a plain fieldname, which will just get passed on
2) an arraryref of fieldname and order direction
3) an arraryref of functionhashref, and order direction
4) a function hashref
5) a scalar ref that will be passed on blind as before

This, I hope, won't break current functionality.. or am I missing 
anything?

Jess


On Wed, 21 Jun 2006, Jesper Krogh wrote:

>
> This patch makes quote_char and order by work without breaking "too much".
>
> As castaway cleverly pointed out, then it wont work when columnnames have
> spaces in them.
>
> Suggestion for a permanent fix was to make order_by take an array_ref:
>
> ->search({},{order_by => [ { "this.that" => "desc"},{"this.id" => "asc"}]});
>
> This can be implemneted without breaking the current order_by that only
> takes a scalar as argument..  Is this viable?
>
> ... this it not the patch to do the above... but to make it semi-work now.
>
> Index: lib/DBIx/Class/Storage/DBI.pm
> ===================================================================
> --- lib/DBIx/Class/Storage/DBI.pm       (revision 2013)
> +++ lib/DBIx/Class/Storage/DBI.pm       (working copy)
> @@ -193,7 +193,7 @@
>         map { $self->{quote_char}->[0] . $_ . $self->{quote_char}->[1]  }
>        split(/\Q$sep\E/,$label));
>   }
> -  return $self->SUPER::_quote($label);
> +  return join(" ",map { $_ !~ /^(asc|desc)$/i ? $self->SUPER::_quote($_)
> : $_ } split(" ",$label));
> }
>
> sub _RowNum {
>
> Jesper
> -- 
> Jesper Krogh
>
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
>



More information about the Dbix-class mailing list