On Wed, 2010-07-07 at 10:18 +0100, Chris Cole wrote:
> I'm finding when restricting a search on the same column for multiple 
> criteria only one of them is being applied. e.g.
> 
> my $rs = $self->resultset('NgsMappings')->search(
>     {
>        'mp_start'  => {'>=', $start},
>        'mp_start'  => {'<', $end},
>        'rs_name'   => $chr,
>        'me_sample' => {'like', $dataset},
>     },
>     {
>        columns => [qw/mp_strand mp_start mp_end mp_freq/],
>        join => [qw/mp_me_id mp_ref_id/],
>     }
> );
> 
> Gives this SQL (note the single use of 'mp_start'):
> SELECT me.mp_strand, me.mp_start, me.mp_end, me.mp_freq
> FROM ngs_mappings me
> JOIN ngs_map_exps mp_me_id ON mp_me_id.me_id = me.mp_me_id
> JOIN ngs_ref_seqs mp_ref_id ON mp_ref_id.rs_id = me.mp_ref_id
> WHERE ( ( me_sample LIKE ? AND mp_start < ? AND rs_name = ? ) ) : 
> 'FPAox%', '5446714', 'chr1'
> 
> I can't find anything in the documentation regarding this, so is it a 
> bug or am I missing something (probably)?


no, no bug....its a hash ref you are sending to the search so when you
use mp_start twice like that one of the values will be overwriting the
other.

to search twice on the same field you could try something like this:

{
    mp_start => { '>=', $start, '<', $end, },
}

Stuart.

-- 

==========================================================
united-domains AG - The Domain People.
Gautinger Strasse 10
D-82319 Starnberg
Tel. + 49 (0) 81 51 / 3 68 67 - 33
Fax + 49 (0) 81 51 / 3 68 67 - 77
http://www.united-domains.de
----------------------------------------------------------
Sitz: Starnberg, HRB 127020 (AG München)
Vorstand: Florian Huber (Vors.)
Alexander Helm, Markus Eggensperger
Aufsichtsrat: Norbert Lang (Vors.)
==========================================================

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
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/[email protected]

Reply via email to