On 09/11/10 13:49, Steve wrote:
It appears that you are *not* chaining these resultsets...

If you first do...
# Narrow the search down if the start date is supplied.
$date_ranges = $rs->search({
start_date => { '<=', $start_date },
end_date => { '>=', $start_date },
}) if $start_date;

then in order to 'chain' you must...

$date_ranges = $date_ranges->search({...

You overwrote your resultset when you...

# Narrow the search down if the end date is supplied.
$date_ranges = $rs->search({
start_date => { '<=', $end_date },
end_date => { '>=', $end_date },
}) if $end_date;

Sorry, that was my mistake when reducing my original code down for the email. You are right - it should have read:

###

# Create a search.
my $date_ranges = $rs->search({});

# Narrow the search down if the start date is supplied.
$date_ranges = $date_ranges->search({
    start_date => { '<=', $start_date },
    end_date   => { '>=', $start_date },
}) if $start_date;

# Narrow the search down if the end date is supplied.
$date_ranges = $date_ranges->search({
    start_date => { '<=', $end_date },
    end_date   => { '>=', $end_date },
}) if $end_date;

###

_______________________________________________
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