chore: find inherit collection warn (#1663)
This commit is contained in:
parent
59326dbf90
commit
c3a91e9758
@ -390,20 +390,24 @@ export class Database extends EventEmitter implements AsyncEmitter {
|
|||||||
this.on('afterRepositoryFind', ({ findOptions, dataCollection, data }) => {
|
this.on('afterRepositoryFind', ({ findOptions, dataCollection, data }) => {
|
||||||
if (dataCollection.isParent()) {
|
if (dataCollection.isParent()) {
|
||||||
for (const row of data) {
|
for (const row of data) {
|
||||||
const rowCollectionName = this.tableNameCollectionMap.get(
|
const rowCollection = this.tableNameCollectionMap.get(
|
||||||
findOptions.raw
|
findOptions.raw
|
||||||
? `${row['__schemaName']}.${row['__tableName']}`
|
? `${row['__schemaName']}.${row['__tableName']}`
|
||||||
: `${row.get('__schemaName')}.${row.get('__tableName')}`,
|
: `${row.get('__schemaName')}.${row.get('__tableName')}`,
|
||||||
).name;
|
);
|
||||||
|
|
||||||
if (!rowCollectionName) {
|
if (!rowCollection) {
|
||||||
throw new Error(
|
this.logger.warn(
|
||||||
`Can not find collection by table name ${rowCollectionName}, current collections: ${Array.from(
|
`Can not find collection by table name ${JSON.stringify(row)}, current collections: ${Array.from(
|
||||||
this.tableNameCollectionMap.keys(),
|
this.tableNameCollectionMap.keys(),
|
||||||
).join(', ')}`,
|
).join(', ')}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rowCollectionName = rowCollection.name;
|
||||||
|
|
||||||
findOptions.raw
|
findOptions.raw
|
||||||
? (row['__collection'] = rowCollectionName)
|
? (row['__collection'] = rowCollectionName)
|
||||||
: row.set('__collection', rowCollectionName, {
|
: row.set('__collection', rowCollectionName, {
|
||||||
|
Loading…
Reference in New Issue
Block a user