On 07/07/10 10:38, Stuart Dodds wrote:
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.
Ah, of course!
to search twice on the same field you could try something like this:
{
mp_start => { '>=', $start, '<', $end, },
}
That did it. Thanks.
_______________________________________________
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]