From 00048a2d3e797e710ef640d15b77289035026631 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 9 Oct 2024 17:04:27 +0100 Subject: [PATCH] Addressing PR comments. --- packages/backend-core/src/sql/sql.ts | 16 ++++++---------- .../src/api/controllers/row/ExternalRequest.ts | 6 ++++-- packages/server/src/api/routes/tests/row.spec.ts | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index 05b38db309..f122ad1c41 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -326,17 +326,13 @@ class InternalBuilder { } private parseBody(body: Record) { - try { - for (let [key, value] of Object.entries(body)) { - const { column } = this.splitter.run(key) - const schema = this.table.schema[column] - if (!schema) { - continue - } - body[key] = this.parse(value, schema) + for (let [key, value] of Object.entries(body)) { + const { column } = this.splitter.run(key) + const schema = this.table.schema[column] + if (!schema) { + continue } - } catch (err) { - console.log(err) + body[key] = this.parse(value, schema) } return body } diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 3510b5ed75..56522acb33 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -671,6 +671,7 @@ export class ExternalRequest { config.includeSqlRelationships === IncludeRelationship.INCLUDE // clean up row on ingress using schema + const unprocessedRow = config.row const processed = this.inputProcessing(row, table) row = processed.row let manyRelationships = processed.manyRelationships @@ -750,9 +751,10 @@ export class ExternalRequest { // we might still need to perform other operations like updating the foreign keys on other rows if ( this.operation === Operation.UPDATE && - Object.keys(row || {}).length === 0 + Object.keys(row || {}).length === 0 && + unprocessedRow ) { - response = [config.row!] + response = [unprocessedRow] } else { response = env.SQL_ALIASING_DISABLE ? await getDatasourceAndQuery(json) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 6f56916ddc..b86ec38d08 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1138,6 +1138,7 @@ describe.each([ status: 200, }) expect(afterRelatedRow.relationship.length).toEqual(1) + expect(afterRelatedRow.relationship[0]._id).toEqual(row._id) }) it("should be able to update relationships when both columns are same name", async () => {