From ab03435c8410d36b2f0cacf3e1a4c15fe6ea45c6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 6 Oct 2021 17:55:03 +0100 Subject: [PATCH] Making sure creation of SQL rows don't pass down null columns (no point). --- packages/server/src/integrations/base/sql.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index a12d8c3c08..4130900217 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -141,6 +141,12 @@ function buildCreate( const { endpoint, body } = json let query: KnexQuery = knex(endpoint.entityId) const parsedBody = parseBody(body) + // make sure no null values in body for creation + for (let [key, value] of Object.entries(parsedBody)) { + if (value == null) { + delete parsedBody[key] + } + } // mysql can't use returning if (opts.disableReturning) { return query.insert(parsedBody)