feat(database): show table comments in the database tree (#6416)

Tables and views in the Database tree now show their comment in grey after the name, with the full comment as the row tooltip. Built-in drivers read it in the same catalog query that lists relations (PostgreSQL, MySQL, Oracle, ClickHouse, Snowflake, SQL Server extended properties) and JDBC sources from REMARKS. The new Show Table Comments view option is on by default and toggles from the Database window options; TableInfo.comment is optional on the wire.

Co-authored-by: wangyuewen-china <[email protected]>
Цей коміт міститься в:
Waiting-Night authored and GitHub committed 2026-11-27 16:48:31 +08:00
1 джерело 3a1353cc0e
коміт 2e93422270
18 files changed
+150 -32

No files matched your search

Бінарний файл не відображається.
+2 -2
Переглянути файл
@@ -138,13 +138,13 @@ public final class OpenIdeaJdbc {
String catalog = catalogs && !name.isEmpty() ? name : connection.getCatalog();
String schema = catalogs || name.isEmpty() ? null : pattern(m, name);
if (op.equals("tables")) {
header(out, "name", "kind");
header(out, "name", "kind", "comment");
try (ResultSet rs = m.getTables(catalog, schema, "%", null)) {
int n = 0;
while (rs.next() && n < 20000) {
String type = rs.getString("TABLE_TYPE").toLowerCase(Locale.ROOT);
if (!Set.of("table","base table","view","materialized view","system table","local temporary","foreign table").contains(type)) continue;
row(out, rs.getString("TABLE_NAME"), type);
row(out, rs.getString("TABLE_NAME"), type, rs.getString("REMARKS"));
n++;
}
}
+5
Переглянути файл
@@ -32,6 +32,8 @@ public class SelfTest {
case "getIdentifierQuoteString" -> "\"";
case "getSearchStringEscape" -> "\\";
case "getSchemas" -> rows(List.of(Map.of("TABLE_SCHEM", "app")));
case "getTables" -> rows(List.of(Map.of(
"TABLE_NAME", "orders", "TABLE_TYPE", "TABLE", "REMARKS", "Orders table")));
case "getColumns" -> "app".equals(a[1]) && "%".equals(a[2]) ? rows(List.of(
Map.of("TABLE_NAME", "orders", "COLUMN_NAME", "id", "TYPE_NAME", "INT", "NULLABLE", 0),
Map.of("TABLE_NAME", "orders", "COLUMN_NAME", "note", "TYPE_NAME", "VARCHAR", "NULLABLE", 1,
@@ -155,6 +157,9 @@ public class SelfTest {
var columns = new String(reply(in), StandardCharsets.UTF_8);
assert columns.contains("orders") && columns.contains("note") && columns.contains("'none'") : columns;
assert columns.contains("comment") && columns.contains("free text") : columns;
send(out, 10, "tables", "app");
var tables = new String(reply(in), StandardCharsets.UTF_8);
assert tables.contains("orders") && tables.contains("Orders table") : tables;
} finally {
child.destroyForcibly().waitFor();
}