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.
--- a/teal-src/util/datamapper.tl Wed Mar 24 00:34:22 2021 +0100
+++ b/teal-src/util/datamapper.tl Wed Mar 24 00:48:02 2021 +0100
@@ -168,7 +168,10 @@
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
--- a/util/datamapper.lua Wed Mar 24 00:34:22 2021 +0100
+++ b/util/datamapper.lua Wed Mar 24 00:48:02 2021 +0100
@@ -138,7 +138,10 @@
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