Changeset

11481:b2f9782497dd

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.
author Kim Alvefur <zash@zash.se>
date Wed, 24 Mar 2021 00:48:02 +0100
parents 11480:0aa2971380e9
children 11482:671f6b867e0d
files teal-src/util/datamapper.tl util/datamapper.lua
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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