Skip to content

Add next-value buffering to Bio::EnsEMBL::Utils::Iterator

Marek Szuba requested to merge github/fork/muffato/master into master

Created by: muffato

Use case

I'm instantiating a Bio::EnsEMBL::Utils::Iterator with a simple sub that does this:

my $fetch_sub = sub {
    return $sth->fetchrow_arrayref;
}

Then, when I iterate I get this error: DBD::mysql::st fetchrow_arrayref failed: fetch() without execute()

This is because $iterator->has_next() keeps on calling the coderef even though it has already returned undef and DBD::mysql::st thinks enough is enough.

Description

Here, I use exists instead of defined and I leave undef in $self->{next} once it's been reached.

Benefits

Can use DBI fetch methods in the iterator

Possible Drawbacks

N/A

Testing

Have you added/modified unit tests to test the changes?

Yes

If so, do the tests pass/fail?

Yes

Have you run the entire test suite and no regression was detected?

Yes

Merge request reports