LibreCat / Catmandu-DBI

A Catmandu::Store plugin for DBI based interfaces
Other
0 stars 1 forks source link

set total when reaching end to avoid total=1 and so infinite queries #34

Closed nicolasfranck closed 2 years ago

nicolasfranck commented 2 years ago

The generator of Catmandu::Store::DBI::Iterator keeps executing queries (with offset increased by the limit parameter), even beyond the result boundary. The reason for this is that this line is never executed because decrementing of $total is skipped as soon as $rows is empty. So $total gets stuck at 1. I've changed the code to reset $total to the number of returned rows from the queries because that means that there won't be any more results.

results 0 - 99 results 100 - 199 results 200 - 201 -> here the generator keeps executing queries

nicolasfranck commented 2 years ago

BTW. this does not "fix" a bug, the iterator still returns the correct number of results. It just removes unnecessary queries.