diff --git a/packages/tools/src/DatabaseAnalyser.ts b/packages/tools/src/DatabaseAnalyser.ts index e49aaf922..a61c19612 100644 --- a/packages/tools/src/DatabaseAnalyser.ts +++ b/packages/tools/src/DatabaseAnalyser.ts @@ -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'); diff --git a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js index 3a316a99d..5bdea1959 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js @@ -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 => {