From 45741c3609d5618ca22ef0a615e26d51b55c787d Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Mon, 28 Jun 2021 19:23:47 +0530 Subject: [PATCH] fix: Postgres hooks params and condition bugs re #309 Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com> --- packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts | 5 +++++ packages/nocodb/src/lib/noco/common/BaseModel.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts index 650a296d69..6d6599c1dd 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts @@ -272,6 +272,11 @@ class BaseModelSql extends BaseModel { response = data; } } + + if (Array.isArray(response)) { + response = response[0]; + } + await this.afterInsert(response, trx, cookie); return Array.isArray(response) ? response[0] : response; } catch (e) { diff --git a/packages/nocodb/src/lib/noco/common/BaseModel.ts b/packages/nocodb/src/lib/noco/common/BaseModel.ts index ca5a9e7376..f6209ee231 100644 --- a/packages/nocodb/src/lib/noco/common/BaseModel.ts +++ b/packages/nocodb/src/lib/noco/common/BaseModel.ts @@ -137,6 +137,7 @@ class BaseModel> extends BaseModelSql { return typeof value === 'string' ? this.parseBody(value, apiReq, data, apiMeta) : value; }); } catch (e) { + apiMeta.body = this.parseBody(apiMeta.body, apiReq, data, apiMeta) console.log(e); } } @@ -146,6 +147,7 @@ class BaseModel> extends BaseModelSql { return typeof value === 'string' ? this.parseBody(value, apiReq, data, apiMeta) : value; }); } catch (e) { + apiMeta.auth = this.parseBody(apiMeta.auth, apiReq, data, apiMeta) console.log(e); } } @@ -157,7 +159,7 @@ class BaseModel> extends BaseModelSql { } return paramsObj; }, {}) : {}, - url: apiMeta.path, + url: this.parseBody(apiMeta.path, apiReq, data, apiMeta), method: apiMeta.method, data: apiMeta.body, headers: apiMeta.headers ? apiMeta.headers.reduce((headersObj, header) => {