[Dbix-class] quote char works with sorting without breaking too much!
Ash Berlin
ash at cpan.org
Fri Jun 23 01:34:01 CEST 2006
A. Pagaltzis wrote:
> * Ash Berlin <ash at cpan.org> [2006-06-22 13:50]:
>
>> 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' } ] }
>>
>
> Errm, seriously: you find that more readable than literal SQL?
>
No, just more portable. What if you change the table name but forget to
change it one place in your code, or add an age column to another table
etc. etc.
> As a sidenote, this will take effort to implement, because you’re
> using the same notation for `case` as for functions, which means
> the SQL renderer has to know it’s not, which means it needs
> hardwired knowledge of specific constructs. And what about
> vendor-specific SQL extensions.
>
$ash_said = q{Of course this would require special code to detect the
case "function"}
> All of this so you can cast fairly clean SQL as a jumble of
> brackets, braces and arrows.
>
> I’m unconvinced. :-(
>
> Regards,
>
More information about the Dbix-class
mailing list