diff options
author | Kim Alvefur <zash@zash.se> | 2025-04-14 15:10:29 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2025-04-14 15:10:29 +0200 |
commit | 7e16a71be809f444029bbbdc401f686f912e7028 (patch) | |
tree | 8cc2a95c0bd05f1be613dcac66ad25594d11ac94 /spec | |
parent | 7340c4e1f264712771933cb8455511fc09cda442 (diff) | |
download | prosody-7e16a71be809f444029bbbdc401f686f912e7028.tar.gz prosody-7e16a71be809f444029bbbdc401f686f912e7028.zip |
mod_storage_internal: Fix queries with only start returning extra itemsorigin/13.013.0
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
Diffstat (limited to 'spec')
-rw-r--r-- | spec/core_storagemanager_spec.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/core_storagemanager_spec.lua b/spec/core_storagemanager_spec.lua index 32a8d6f0..a6857d0c 100644 --- a/spec/core_storagemanager_spec.lua +++ b/spec/core_storagemanager_spec.lua @@ -436,6 +436,44 @@ describe("storagemanager", function () assert.equal(#test_data - 3, count); end); + it("by time (start before first item)", function () + -- luacheck: ignore 211/err + local data, err = archive:find("user", { + ["start"] = test_time-5; + }); + assert.truthy(data); + local count = 0; + for id, item, when in data do + count = count + 1; + assert.truthy(id); + assert(st.is_stanza(item)); + assert.equal("test", item.name); + assert.equal("urn:example:foo", item.attr.xmlns); + assert.equal(2, #item.tags); + assert(when >= test_time-5, ("%d >= %d"):format(when, test_time-5)); + end + assert.equal(#test_data, count); + end); + + it("by time (start after last item)", function () + -- luacheck: ignore 211/err + local data, err = archive:find("user", { + ["start"] = test_time+5; + }); + assert.truthy(data); + local count = 0; + for id, item, when in data do + count = count + 1; + assert.truthy(id); + assert(st.is_stanza(item)); + assert.equal("test", item.name); + assert.equal("urn:example:foo", item.attr.xmlns); + assert.equal(2, #item.tags); + assert(when >= test_time+5, ("%d >= %d"):format(when, test_time+5)); + end + assert.equal(0, count); + end); + it("by time (start+end)", function () -- luacheck: ignore 211/err local data, err = archive:find("user", { |