[Dbix-class] order_by problem with paged results - column name withspaces...

Michael Higgins mhiggins at banfieldgroup.com
Mon Apr 23 19:38:11 GMT 2007


 

> -----Original Message-----
> From: Michael Higgins [mailto:mhiggins at banfieldgroup.com] 

> SQL::Abstract::Limit _seems_ responsible for the errors. If I 
> pass the reference, it carps about ORDER BY SCALAR(0x85d842c) 
> DESC and if I don't, then it complains bad column order spec: 
> "Invoice #" DESC.

[8<]

> However, from SQL::Abstract::Limit:
> 
>     my $ref = ref $order;
> 
>     my @order;
> 
> CASE: {
>     @order = @$order,     last CASE if $ref eq 'ARRAY';
>     @order = ( $order ),  last CASE unless $ref;
>     @order = ( $$order ), last CASE if $ref eq 'SCALAR';
>     Carp::croak __PACKAGE__ . ": Unsupported data struct $ref 
> for ORDER BY"; }
>     foreach my $spec ( @order )
>     {

So, I altered the module...

my @spec;
my ($col, $up);
if (! ref $spec){
        @spec = split ' ', $spec;
        Carp::croak( "bad column order spec: $spec" ) if @spec > 2;
        push( @spec, 'ASC' ) unless @spec == 2;
        ( $col, $up ) = @spec; # or maybe down
}else {
my $lastspace = (rindex $$spec, ' ') +1;
$col = substr $$spec, 0, $lastspace;
$up = substr $$spec, $lastspace;
}


Obviously, this ain't a real patch. But, it got me around the problem... I
think. At least, I believe I've isolated the glitch...

Is there another way to honor the 'pass this sql through like it is' for
order_by with paged results?

Cheers,

-- 
Michael Higgins





More information about the Dbix-class mailing list