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

Moritz Onken onken at houseofdesign.de
Mon Jul 21 08:59:17 BST 2008


Hi,

referring to
 > http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/Manual/Cookbook.pod#Using_SQL_functions_on_the_left_hand_side_of_a_comparison
I tried to run this query:

$rs->search({
   -and =>
     [
      {"extract(year from age(NOW(),birthday))" => 22},
      {sex => "male"}
     ]
});

The problem is, that quoting is enabled and the docs say that I have  
to pass the query in the where attribute:
$rs->search({}, { where => \'YEAR(date_of_birth) = 1979' });

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"}
     ]
});



greetings,

moritz



More information about the DBIx-Class mailing list