aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-24 00:48:02 +0100
committerKim Alvefur <zash@zash.se>2021-03-24 00:48:02 +0100
commit4720eea24f8fa382c778ecf28dd0e98a2c43c1d3 (patch)
tree2517499dec8316a1323578931bccc5d23e593a3a
parentd68de27a5dffaae65b82cdb45e6cae415ce305a5 (diff)
downloadprosody-4720eea24f8fa382c778ecf28dd0e98a2c43c1d3.tar.gz
prosody-4720eea24f8fa382c778ecf28dd0e98a2c43c1d3.zip
util.datamapper: Don't include empty unwrapped arrays
Since there is no way to distinguish an empty such array from a zero-length array. Dropping it seems like the least annoying thing to do.
-rw-r--r--teal-src/util/datamapper.tl5
-rw-r--r--util/datamapper.lua5
2 files changed, 8 insertions, 2 deletions
diff --git a/teal-src/util/datamapper.tl b/teal-src/util/datamapper.tl
index 99431f86..ed7ce62c 100644
--- a/teal-src/util/datamapper.tl
+++ b/teal-src/util/datamapper.tl
@@ -168,7 +168,10 @@ function parse_object (schema : schema_t, s : st.stanza_t) : { string : any }
out[prop] = parse_object(propschema, c);
end
elseif proptype == "array" then
- out[prop] = parse_array(propschema, s);
+ local a = parse_array(propschema, s);
+ if a and a[1] ~= nil then
+ out[prop] = a;
+ end
else
error "unreachable"
end
diff --git a/util/datamapper.lua b/util/datamapper.lua
index 68c09434..00c75a25 100644
--- a/util/datamapper.lua
+++ b/util/datamapper.lua
@@ -138,7 +138,10 @@ function parse_object(schema, s)
out[prop] = parse_object(propschema, c);
end
elseif proptype == "array" then
- out[prop] = parse_array(propschema, s);
+ local a = parse_array(propschema, s);
+ if a and a[1] ~= nil then
+ out[prop] = a;
+ end
else
error("unreachable")
end