[Dbix-class] Problems using a database function in the where clause

Moritz Onken onken at houseofdesign.de
Tue Jul 22 08:14:15 BST 2008


Am 21.07.2008 um 15:01 schrieb Eden Cardim:

> On Mon, Jul 21, 2008 at 4:59 AM, Moritz Onken  
> <onken at houseofdesign.de> wrote:
>> But how can I rewrite my query to the other format without writing  
>> the raw
>> sql where clause?
>> Why is it not possible to write my query with as scalar ref:
>>
>> $rs->search({
>> -and =>
>>   [
>>    {\"extract(year from age(NOW(),birthday))" => 22},
>>    {sex => "male"}
>>   ]
>> });
>
> Because the '=>' operator stringifies it's left operand, thus you'll
> end up with some perl internal debug value instead of the string you
> intended. What's the problem with writing raw SQL?

The idea of DBIC is not to write raw sql, right?




More information about the DBIx-Class mailing list