diff --git a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js index fb536c5f..9d23c8a7 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js @@ -199,19 +199,23 @@ class Analyser extends DatabaseAnalyser { x.schema_name == table.schema_name && !uniqueNames.rows.find(y => y.constraint_name == x.index_name) ) - .map(idx => ({ - constraintName: idx.index_name, - isUnique: idx.is_unique, - columns: _.compact( - idx.indkey - .split(' ') - .map(colid => indexcols.rows.find(col => col.oid == idx.oid && col.attnum == colid)) - .filter(col => col != null) - .map(col => ({ - columnName: col.column_name, - })) - ), - })), + .map(idx => { + const indOptionSplit = idx.indoption.split(' '); + return { + constraintName: idx.index_name, + isUnique: idx.is_unique, + columns: _.compact( + idx.indkey + .split(' ') + .map(colid => indexcols.rows.find(col => col.oid == idx.oid && col.attnum == colid)) + .filter(col => col != null) + .map((col, colIndex) => ({ + columnName: col.column_name, + isDescending: parseInt(indOptionSplit[colIndex]) > 0, + })) + ), + }; + }), uniques: indexes.rows .filter( x => diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/indexes.js b/plugins/dbgate-plugin-postgres/src/backend/sql/indexes.js index 06922b15..8cb8de24 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/indexes.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/indexes.js @@ -6,6 +6,7 @@ module.exports = ` ix.indisprimary as "is_primary", ix.indisunique as "is_unique", ix.indkey as "indkey", + ix.indoption as "indoption", t.oid as "oid" from pg_class t,