{"record":{"id":"9bb0e3df3216550f","repo":"nocobase/nocobase","slug":"can-not-find-collection-by-table-name-json-strin","errorCode":null,"errorMessage":"Can not find collection by table name ${JSON.stringify(row)}, current collections: ${Array.from(db.tableNameCollectionMap.keys()).join(', ')}","messagePattern":"Can not find collection by table name (.+?), current collections: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/database/src/listeners/append-child-collection-name-after-repository-find.ts","lineNumber":47,"sourceCode":"      }\n\n      return;\n    }\n\n    if (dataCollection.isParent()) {\n      for (const row of data) {\n        if (row.__collection) {\n          continue;\n        }\n\n        const fullTableName = findOptions.raw\n          ? `${row['__schemaName']}.${row['__tableName']}`\n          : `${row.get('__schemaName')}.${row.get('__tableName')}`;\n\n        const rowCollection = db.tableNameCollectionMap.get(fullTableName);\n\n        if (!rowCollection) {\n          db.logger.warn(\n            `Can not find collection by table name ${JSON.stringify(row)}, current collections: ${Array.from(\n              db.tableNameCollectionMap.keys(),\n            ).join(', ')}`,\n          );\n\n          return;\n        }\n\n        const rowCollectionName = rowCollection.name;\n\n        setRowAttribute(row, '__collection', rowCollectionName, findOptions.raw);\n      }\n    }\n  };\n};\n","sourceCodeStart":29,"sourceCodeEnd":63,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/core/database/src/listeners/append-child-collection-name-after-repository-find.ts#L29-L63","documentation":"After a repository find on an inherited-collection query, this listener maps each row's __schemaName/__tableName back to a collection via db.tableNameCollectionMap. When no collection matches the row's physical table name, the row is skipped with this warning instead of crashing.","triggerScenarios":"Querying an inherited collection returns rows whose physical table has no registered collection — e.g. the child table exists in the DB but its collection/plugin was removed, or a raw query returns tables outside the current collections.","commonSituations":"Disabling a plugin whose tables remain in the database; raw SQL joined tables; stale tableNameCollectionMap after collection reload; multi-schema setups where the schema prefix doesn't match.","solutions":["Identify the unknown table from the logged list and either register its collection or remove the orphan table from the database.","Enable the plugin that owns the missing collection so it is registered.","If the table is a leftover, drop it (after backup) so inherited queries no longer return it.","Re-run `yarn nocobase upgrade` / refresh collections to resync tableNameCollectionMap."],"exampleFix":"// before\nSELECT * FROM parent_collection; // returns rows from orphan table 'old_child'\n// after\ndrop legacy table or re-enable its plugin, then re-run the query","handlingStrategy":"validation","validationCode":"const known = new Set(db.tableNameCollectionMap.keys());\nconst orphans = rows.map((r) => `${r.__schemaName}.${r.__tableName}`).filter((t) => !known.has(t));\nif (orphans.length) console.warn('Unmapped tables in result:', orphans);","typeGuard":null,"tryCatchPattern":"try {\n  const result = await repository.find(options);\n} catch (e) {\n  logger.warn(`inherited find issue: ${e.message}`);\n  const result = await repository.find({ ...options, filter: {} });\n}","preventionTips":["Drop or re-register orphan tables left behind by disabled plugins.","Keep inherited-collection children's plugins enabled with the parent.","Refresh collections (yarn nocobase upgrade) after schema changes.","Avoid raw SQL joining unknown tables into inherited finds."],"tags":["database","inherited-collections","table-mapping"],"backgroundTag":"table-name-not-mapped","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}