From: "Peter Rabbitson" <rabbit+d...@rabbit.us>

> On Tue, Dec 18, 2012 at 10:53:25AM +0200, Octavian Rasnita wrote:
>> From: "Peter Rabbitson" <rabbit+d...@rabbit.us>
>> 
>> > On Mon, Dec 17, 2012 at 11:04:22AM +0100, QE :: Felix Ostmann wrote:
>> >> I am doing such a order with the following SQL:
>> >> 
>> >> ...
>> >> ORDER BY
>> >>   (department = 'Marketing') DESC,
>> >>   (department = 'Sales') DESC,
>> >>   (department = 'Financial') DESC,
>> >>   (department = 'IT') DESC,
>> >>   (department = 'Operations') DESC,
>> >>   ...
>> >> 
>> >> But there is no special way to use this with DBIx::Class :-/
>> >> 
>> > 
>> > Can you elaborate? You can always do:
>> > 
>> > order_by => \' anything you feel like goes here'.
>> > 
>> > Is this not sufficient?
>> > 
>> > Cheers
>> > 
>> 
>> 
>> 
>> I can do:
>> 
>> order_by => \'field(department, "Marketing", "Sales", "IT")',
>> 
>> But the problem is that those names of the departments should be manually 
>> cleaned/escaped before inserting them in that script, to avoid SQL injection.
>> 
> 
> Well - you need to check beforehand anyway if the requested columns are
> in fact available. Or are you just letting the RDBMS throw in this case?
> 
>> And another problem might be that the syntax above won't be portable to 
>> other databases.
> 
> But the *concept* itself is not sanely portable to many RDBMS. Hence
> giving this technique space in the official API seems unwise.


Oh, in this case, searching for portability is useless indeed.

Thanks.

Octavian


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to