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

Ash Berlin ash at cpan.org
Thu Jun 22 13:42:04 CEST 2006


A. Pagaltzis wrote:
> * Ash Berlin <ash at cpan.org> [2006-06-21 17:05]:
>   
>> Hows about:
>>
>> order_by => [ asc => 'name', 'lastname', desc => {sum => [ 'age' ] } ]
>>
>> (A cross between yours and what Jess had)
>>     
>
> What’s the point of that arrayref? What does the following mean?
>
>     { sum => [ 'foo', 'bar' ] }
>
> Also, what syntax do folks suggest for specifying something like
> the following contrived order clause?
>
>     CASE
>         WHEN age < 18 THEN NULL
>         WHEN age > 45 THEN NULL
>         ELSE age
>     END
>
> Or think about writing casts.
>
> Seems pretty pointless to me to invent any syntax beyond
> accepting literal SQL…
>
> Regards,
>   
The reason for they array ref is if a function takes more than one param.

As for a go at taking that contrived CASE clause:

{ case => [ [ age => '<' => 18 => 'NULL'], [age => '>' => 45 => 'NULL'], 
['age'] ] }

Possible with WHEN/ELSE keys:

{ case => [ { where => 'age' => '<' => 18 => 'NULL'}, {where => 'age' => 
'>' => 45 => 'NULL'}, { else => 'age' } ] }

(This could also apply as a where clause.) Of course this would require 
special code to detect the case "function" but currently the only other 
solution is raw SQL anyway.

Perhaps overly complex - thoughts?

Ash





More information about the Dbix-class mailing list