[Dbix-class] Constructing a resultset()->search() with variable number of ORs?

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Nov 2 08:47:04 GMT 2009


Chris Cole wrote:
> Hi,
> 
> I'd like to convert the below code to using a variable number of ORs on
> the 'name' column. i.e. there may be a data3 as well as data1 and data2.
> 
> my $schema = DB::Schema->connect();
> 
> my @rows = $schema->resultset('Reads2expt')->search(
>    # select name rows on data1 OR data2 with abundance cutoffs
>    [
>       {
>          name => 'data1',
>          abundance => { '>' => 1 }
>       },
>       {
>          name => 'data2',
>          abundance => { '>' => 1 }
>       }
>    
>    ],

...

o.O Why not simply:

search ({ abundance => { '>', 1 }, name => \@list_of_possible_names }, {...} );



More information about the DBIx-Class mailing list