From e7318230fdc1aa3b6694442ae8c3594f75e7b295 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 28 Jul 2023 14:21:17 +0530 Subject: [PATCH 1/2] fix: throw the actual error and avoid dataloader error to avoid confusion Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 107 ++++++++++------------- 1 file changed, 46 insertions(+), 61 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index f39079c2fd..7abe83ca41 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -1385,30 +1385,25 @@ class BaseModelSqlv2 { if (colOptions?.type === 'hm') { const listLoader = new DataLoader(async (ids: string[]) => { - try { - if (ids.length > 1) { - const data = await this.multipleHmList( + if (ids.length > 1) { + const data = await this.multipleHmList( + { + colId: column.id, + ids, + }, + (listLoader as any).args, + ); + return ids.map((id: string) => (data[id] ? data[id] : [])); + } else { + return [ + await this.hmList( { colId: column.id, - ids, + id: ids[0], }, (listLoader as any).args, - ); - return ids.map((id: string) => (data[id] ? data[id] : [])); - } else { - return [ - await this.hmList( - { - colId: column.id, - id: ids[0], - }, - (listLoader as any).args, - ), - ]; - } - } catch (e) { - console.log(e); - return []; + ), + ]; } }); const self: BaseModelSqlv2 = this; @@ -1429,31 +1424,26 @@ class BaseModelSqlv2 { // }); } else if (colOptions.type === 'mm') { const listLoader = new DataLoader(async (ids: string[]) => { - try { - if (ids?.length > 1) { - const data = await this.multipleMmList( + if (ids?.length > 1) { + const data = await this.multipleMmList( + { + parentIds: ids, + colId: column.id, + }, + (listLoader as any).args, + ); + + return data; + } else { + return [ + await this.mmList( { - parentIds: ids, + parentId: ids[0], colId: column.id, }, (listLoader as any).args, - ); - - return data; - } else { - return [ - await this.mmList( - { - parentId: ids[0], - colId: column.id, - }, - (listLoader as any).args, - ), - ]; - } - } catch (e) { - console.log(e); - return []; + ), + ]; } }); @@ -1476,26 +1466,21 @@ class BaseModelSqlv2 { colId: colOptions.fk_child_column_id, }); const readLoader = new DataLoader(async (ids: string[]) => { - try { - const data = await ( - await Model.getBaseModelSQL({ - id: pCol.fk_model_id, - dbDriver: this.dbDriver, - }) - ).list( - { - // limit: ids.length, - where: `(${pCol.column_name},in,${ids.join(',')})`, - fieldsSet: (readLoader as any).args?.fieldsSet, - }, - true, - ); - const gs = groupBy(data, pCol.title); - return ids.map(async (id: string) => gs?.[id]?.[0]); - } catch (e) { - console.log(e); - return []; - } + const data = await ( + await Model.getBaseModelSQL({ + id: pCol.fk_model_id, + dbDriver: this.dbDriver, + }) + ).list( + { + // limit: ids.length, + where: `(${pCol.column_name},in,${ids.join(',')})`, + fieldsSet: (readLoader as any).args?.fieldsSet, + }, + true, + ); + const gs = groupBy(data, pCol.title); + return ids.map(async (id: string) => gs?.[id]?.[0]); }); // defining HasMany count method within GQL Type class From 0ba0e216243034b9bbfbe573b341f7e52dbcd8f0 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 28 Jul 2023 14:25:52 +0530 Subject: [PATCH 2/2] chore: update start and build commands Signed-off-by: Pranav C --- packages/nocodb/package.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index 9375bf4db9..f5c2acd199 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -17,14 +17,12 @@ }, "license": "AGPL-3.0-or-later", "scripts": { - "build": "nest build", + "build": "npm run docker:build", "build:obfuscate": "EE=true webpack --config webpack.config.js", "obfuscate:build:publish": "npm run build:obfuscate && npm publish .", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "start": "nest start", - "start:dev": "nest start --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", + "start": "npm run watch:run", + "start:prod": "node docker/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch",