This commit is contained in:
Jan Prochazka 2021-05-16 13:58:22 +02:00
parent 3a08462018
commit 2376cb30db
2 changed files with 3 additions and 4 deletions

View File

@ -33,8 +33,8 @@ export class DatabaseAnalyser {
this.singleObjectFilter = { ...name, typeField };
await this._computeSingleObjectId();
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);
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;
}
@ -104,7 +104,7 @@ export class DatabaseAnalyser {
const { typeField } = this.singleObjectFilter;
if (!this.singleObjectId) return null;
if (!typeFields || !typeFields.includes(typeField)) return null;
return template.replace(/=OBJECT_ID_CONDITION/g, ` = ${this.singleObjectId}`);
return template.replace(/=OBJECT_ID_CONDITION/g, ` = '${this.singleObjectId}'`);
}
if (!this.modifications || !typeFields || this.modifications.length == 0) {
return template.replace(/=OBJECT_ID_CONDITION/g, ' is not null');

View File

@ -57,7 +57,6 @@ class Analyser extends DatabaseAnalyser {
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables']));
const views = await this.driver.query(this.pool, this.createQuery('views', ['views']));
const routines = await this.driver.query(this.pool, this.createQuery('routines', ['procedures', 'functions']));
// console.log('PG fkColumns', fkColumns.rows);
return {
tables: tables.rows.map(table => {