mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 21:57:45 +03:00
util.multitable: Some fixes for iter()... always match against query, and pass value after path results
This commit is contained in:
parent
dd4ba4d3ea
commit
53793b75db
1 changed files with 11 additions and 10 deletions
|
@ -144,18 +144,19 @@ function iter(self, ...)
|
||||||
keys[depth] = key;
|
keys[depth] = key;
|
||||||
end
|
end
|
||||||
local value = stack[depth][key];
|
local value = stack[depth][key];
|
||||||
if depth == maxdepth then -- Result
|
if query[depth] == nil or key == query[depth] then
|
||||||
local result = {}; -- Collect keys forming path to result
|
if depth == maxdepth then -- Result
|
||||||
for i = 1, depth do
|
local result = {}; -- Collect keys forming path to result
|
||||||
result[i] = keys[i];
|
for i = 1, depth do
|
||||||
|
result[i] = keys[i];
|
||||||
|
end
|
||||||
|
result[depth+1] = value;
|
||||||
|
return unpack(result, 1, depth+1);
|
||||||
|
elseif type(value) == "table" then
|
||||||
|
t_insert(stack, value); -- Descend
|
||||||
end
|
end
|
||||||
return unpack(result, 1, depth);
|
|
||||||
else
|
|
||||||
if (query[depth] == nil or key == query[depth]) and type(value) == "table" then -- Descend
|
|
||||||
t_insert(stack, value);
|
|
||||||
end
|
|
||||||
return it(self);
|
|
||||||
end
|
end
|
||||||
|
return it(self);
|
||||||
end;
|
end;
|
||||||
return it, self;
|
return it, self;
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue