Browse Source

fix: Postgres hooks params and condition bugs

re #309

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/341/head
Pranav C 4 years ago
parent
commit
45741c3609
  1. 5
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts
  2. 4
      packages/nocodb/src/lib/noco/common/BaseModel.ts

5
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) {

4
packages/nocodb/src/lib/noco/common/BaseModel.ts

@ -137,6 +137,7 @@ class BaseModel<T extends BaseApiBuilder<any>> 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<T extends BaseApiBuilder<any>> 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<T extends BaseApiBuilder<any>> 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) => {

Loading…
Cancel
Save