From 0ac5c4713a6f4197e348f3ffce99fdc5085dac20 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Fri, 12 Nov 2021 20:23:00 +0000 Subject: [PATCH] Fixing test case (didn't provide a schema). --- packages/server/src/api/routes/tests/misc.spec.js | 6 +++++- packages/server/src/utilities/csvParser.js | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/misc.spec.js b/packages/server/src/api/routes/tests/misc.spec.js index b1dd683060..ae5c0cca60 100644 --- a/packages/server/src/api/routes/tests/misc.spec.js +++ b/packages/server/src/api/routes/tests/misc.spec.js @@ -75,7 +75,11 @@ describe("run misc tests", () => { }, }) const dataImport = { - csvString: "a,b,c,d\n1,2,3,4" + csvString: "a,b,c,d\n1,2,3,4", + schema: {}, + } + for (let col of ["a", "b", "c", "d"]) { + dataImport.schema[col] = { type: "string" } } await tableUtils.handleDataImport( config.getAppId(), diff --git a/packages/server/src/utilities/csvParser.js b/packages/server/src/utilities/csvParser.js index 323c077315..c548a71758 100644 --- a/packages/server/src/utilities/csvParser.js +++ b/packages/server/src/utilities/csvParser.js @@ -77,6 +77,9 @@ function parse(csvString, parsers) { } function updateSchema({ schema, existingTable }) { + if (!schema) { + return schema + } const finalSchema = {} const schemaKeyMap = {} Object.keys(schema).forEach(key => (schemaKeyMap[key.toLowerCase()] = key))