From 50243bb0bc405d84b6961a270e95b8bca6d476df Mon Sep 17 00:00:00 2001 From: Ziggy Jonsson Date: Tue, 30 Jan 2018 18:53:58 -0500 Subject: [PATCH] Don't break if an optional value is `undefined` or `null` --- lib/shred.js | 2 +- test/integration.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/shred.js b/lib/shred.js index 595e007d..b1a0b68e 100644 --- a/lib/shred.js +++ b/lib/shred.js @@ -79,7 +79,7 @@ function shredRecordInternal(fields, record, data, rlvl, dlvl) { // fetch values let values = []; - if (record && (fieldName in record)) { + if (record && (fieldName in record) && record[fieldName] !== undefined && record[fieldName] !== null) { if (record[fieldName].constructor === Array) { values = record[fieldName]; } else { diff --git a/test/integration.js b/test/integration.js index 58bda015..5cfb2089 100644 --- a/test/integration.js +++ b/test/integration.js @@ -68,6 +68,7 @@ function mkTestRows(opts) { rows.push({ name: 'kiwi', price: 4.2, + quantity: undefined, day: new Date('2017-11-26'), date: new Date(TEST_VTIME + 8000 * i), finger: "FNORD",