Mercurial > prosody-hg
diff plugins/mod_storage_internal.lua @ 13847:cbd234461c41 13.0
mod_storage_internal: Fix queries with only start returning extra items
Queries with start > last item would return one item, because there's
some boundary condition in binary_search().
This is here fixed by always applying filters that omit items outside
the requested range.
See also 2374c7665d0b
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 14 Apr 2025 15:10:29 +0200 |
| parents | 8f516d20d288 |
| children | f77911437539 |
line wrap: on
line diff
--- a/plugins/mod_storage_internal.lua Fri Apr 11 09:45:04 2025 +0200 +++ b/plugins/mod_storage_internal.lua Mon Apr 14 15:10:29 2025 +0200 @@ -205,12 +205,11 @@ return query.start - when; end); i = wi - 1; - else - iter = it.filter(function(item) - local when = item.when or datetime.parse(item.attr.stamp); - return when >= query.start; - end, iter); end + iter = it.filter(function(item) + local when = item.when or datetime.parse(item.attr.stamp); + return when >= query.start; + end, iter); end if query["end"] then if query.reverse then @@ -221,12 +220,11 @@ if wi then i = wi + 1; end - else - iter = it.filter(function(item) - local when = item.when or datetime.parse(item.attr.stamp); - return when <= query["end"]; - end, iter); end + iter = it.filter(function(item) + local when = item.when or datetime.parse(item.attr.stamp); + return when <= query["end"]; + end, iter); end if query.after then local found = false;
