From 032eaf9eb014ba143df31a5804789c80ceccd3fd Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 15 May 2021 18:13:20 +0200 Subject: [PATCH] single object analysis refactor --- packages/tools/src/DatabaseAnalyser.ts | 8 ++++++++ packages/tools/src/driverBase.ts | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/tools/src/DatabaseAnalyser.ts b/packages/tools/src/DatabaseAnalyser.ts index 95335676..d5174843 100644 --- a/packages/tools/src/DatabaseAnalyser.ts +++ b/packages/tools/src/DatabaseAnalyser.ts @@ -26,6 +26,14 @@ export class DatabaseAnalyser { return this._runAnalysis(); } + async singleObjectAnalysis(name, typeField) { + this.singleObjectFilter = { ...name, typeField }; + const res = this._runAnalysis(); + if (res[typeField].length == 1) return res[typeField][0]; + const obj = res[typeField].find(x => x.pureName == name.pureName && x.schemaName == name.schemaName); + return obj; + } + async incrementalAnalysis(structure) { this.structure = structure; diff --git a/packages/tools/src/driverBase.ts b/packages/tools/src/driverBase.ts index c5ce2201..a9a9ca3f 100644 --- a/packages/tools/src/driverBase.ts +++ b/packages/tools/src/driverBase.ts @@ -22,12 +22,7 @@ export const driverBase = { }, async analyseSingleObject(pool, name, typeField = 'tables') { const analyser = new this.analyserClass(pool, this); - analyser.singleObjectFilter = { ...name, typeField }; - const res = await analyser.fullAnalysis(); - if (res[typeField].length == 1) return res[typeField][0]; - const obj = res[typeField].find(x => x.pureName == name.pureName && x.schemaName == name.schemaName); - // console.log('FIND', name, obj); - return obj; + return analyser.singleObjectAnalysis(name, typeField); }, analyseSingleTable(pool, name) { return this.analyseSingleObject(pool, name, 'tables');