Browse Source

Merge pull request #6090 from nocodb/refactor/dataloader-error

Avoid dataloader error and throw proper error and update scripts in package.json
pull/6092/head
mertmit 1 year ago committed by GitHub
parent
commit
0132c23630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/nocodb/package.json
  2. 15
      packages/nocodb/src/db/BaseModelSqlv2.ts

8
packages/nocodb/package.json

@ -17,14 +17,12 @@
}, },
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"scripts": { "scripts": {
"build": "nest build", "build": "npm run docker:build",
"build:obfuscate": "EE=true webpack --config webpack.config.js", "build:obfuscate": "EE=true webpack --config webpack.config.js",
"obfuscate:build:publish": "npm run build:obfuscate && npm publish .", "obfuscate:build:publish": "npm run build:obfuscate && npm publish .",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start", "start": "npm run watch:run",
"start:dev": "nest start --watch", "start:prod": "node docker/main",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",

15
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -1390,7 +1390,6 @@ class BaseModelSqlv2 {
if (colOptions?.type === 'hm') { if (colOptions?.type === 'hm') {
const listLoader = new DataLoader(async (ids: string[]) => { const listLoader = new DataLoader(async (ids: string[]) => {
try {
if (ids.length > 1) { if (ids.length > 1) {
const data = await this.multipleHmList( const data = await this.multipleHmList(
{ {
@ -1411,10 +1410,6 @@ class BaseModelSqlv2 {
), ),
]; ];
} }
} catch (e) {
console.log(e);
return [];
}
}); });
const self: BaseModelSqlv2 = this; const self: BaseModelSqlv2 = this;
@ -1434,7 +1429,6 @@ class BaseModelSqlv2 {
// }); // });
} else if (colOptions.type === 'mm') { } else if (colOptions.type === 'mm') {
const listLoader = new DataLoader(async (ids: string[]) => { const listLoader = new DataLoader(async (ids: string[]) => {
try {
if (ids?.length > 1) { if (ids?.length > 1) {
const data = await this.multipleMmList( const data = await this.multipleMmList(
{ {
@ -1456,10 +1450,6 @@ class BaseModelSqlv2 {
), ),
]; ];
} }
} catch (e) {
console.log(e);
return [];
}
}); });
const self: BaseModelSqlv2 = this; const self: BaseModelSqlv2 = this;
@ -1481,7 +1471,6 @@ class BaseModelSqlv2 {
colId: colOptions.fk_child_column_id, colId: colOptions.fk_child_column_id,
}); });
const readLoader = new DataLoader(async (ids: string[]) => { const readLoader = new DataLoader(async (ids: string[]) => {
try {
const data = await ( const data = await (
await Model.getBaseModelSQL({ await Model.getBaseModelSQL({
id: pCol.fk_model_id, id: pCol.fk_model_id,
@ -1497,10 +1486,6 @@ class BaseModelSqlv2 {
); );
const gs = groupBy(data, pCol.title); const gs = groupBy(data, pCol.title);
return ids.map(async (id: string) => gs?.[id]?.[0]); return ids.map(async (id: string) => gs?.[id]?.[0]);
} catch (e) {
console.log(e);
return [];
}
}); });
// defining HasMany count method within GQL Type class // defining HasMany count method within GQL Type class

Loading…
Cancel
Save