From c3a91e9758d6e5d0b338dcf6e947303cd166bfe9 Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Fri, 7 Apr 2023 19:44:44 +0800 Subject: [PATCH] chore: find inherit collection warn (#1663) --- packages/core/database/src/database.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index 2fe22632d..17602d08e 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -390,20 +390,24 @@ export class Database extends EventEmitter implements AsyncEmitter { this.on('afterRepositoryFind', ({ findOptions, dataCollection, data }) => { if (dataCollection.isParent()) { for (const row of data) { - const rowCollectionName = this.tableNameCollectionMap.get( + const rowCollection = this.tableNameCollectionMap.get( findOptions.raw ? `${row['__schemaName']}.${row['__tableName']}` : `${row.get('__schemaName')}.${row.get('__tableName')}`, - ).name; + ); - if (!rowCollectionName) { - throw new Error( - `Can not find collection by table name ${rowCollectionName}, current collections: ${Array.from( + if (!rowCollection) { + this.logger.warn( + `Can not find collection by table name ${JSON.stringify(row)}, current collections: ${Array.from( this.tableNameCollectionMap.keys(), ).join(', ')}`, ); + + return; } + const rowCollectionName = rowCollection.name; + findOptions.raw ? (row['__collection'] = rowCollectionName) : row.set('__collection', rowCollectionName, {