feat(plugins): show table and column comments in sidebar and grid#1782
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e3334a86a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tableRows: TableRows, | ||
| savedLayout: ColumnLayoutState? | ||
| ) { | ||
| let columnComments = AppSettingsManager.shared.general.showObjectComments |
There was a problem hiding this comment.
Include comments in the grid update signature
For the normal editable table path, columnComments are populated later by applyPhase2Metadata, after the first grid render. However, updateNSView only calls reconcileColumnPool when DataGridUpdateSnapshot changes, and that snapshot does not include either tableRows.columnComments or showObjectComments; this line is therefore only evaluated during unrelated structural updates. Opening a MySQL/PostgreSQL table renders header tooltips without the fetched comments, and toggling View > Show Object Comments leaves existing grid tooltips stale until columns/rows or another snapshot field changes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be2b624975
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| columnDefaults = existing.columnDefaults | ||
| columnForeignKeys = existing.columnForeignKeys | ||
| columnNullable = existing.columnNullable | ||
| columnComments = existing.columnComments |
There was a problem hiding this comment.
Clear comments when schema metadata is absent
When a new result has no parsed schema metadata (for example, after previously displaying a commented table in the same tab and then running SELECT 1 AS id), this copies the prior result's columnComments into the new TableRows. The grid keys header tooltips by column name, so any matching alias inherits a stale comment from the previous table even though the result is not that object. Keep comments only when the new result is known to be for the same table/schema; otherwise clear them like fresh metadata.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eadcb834b0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| WHERE table_schema = '\(schemaLiteral)' | ||
| AND table_type IN ('BASE TABLE', 'VIEW') | ||
| SELECT t.table_name, t.table_type, | ||
| obj_description(to_regclass(quote_ident(t.table_schema) || '.' || quote_ident(t.table_name)), 'pg_class') AS table_comment |
There was a problem hiding this comment.
Avoid to_regclass in the base table query
For PostgreSQL 9.1–9.3 connections, this base fetchTables query now fails before any tables are listed because to_regclass(text) is only available starting in PostgreSQL 9.4, while this driver still treats 9.1/9.3 catalogs as supported via PostgreSQLCapabilities (hasForeignTablesCatalog at 90_100 and hasMaterializedViewsCatalog at 90_300). In that environment, opening a schema will error instead of showing tables; use a pg_class/pg_namespace join or gate this expression by server version.
Useful? React with 👍 / 👎.
…ment fetch gracefully (#1782)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4770ce7af6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| result = try await execute(query: baseQuery) | ||
| result = try await execute(query: query(includeOptionalCatalogs: false, includeComments: true)) | ||
| } catch let error as LibPQPluginError where error.sqlState == Self.undefinedFunctionSQLState { | ||
| result = try await execute(query: query(includeOptionalCatalogs: false, includeComments: false)) |
There was a problem hiding this comment.
Keep optional catalogs when comments are unavailable
Fresh evidence in the current revision is that the new undefined-function fallback disables includeOptionalCatalogs as well as comments. On PostgreSQL versions that still support these catalogs here (e.g. pg_foreign_table from 9.1 and pg_matviews from 9.3) but do not have to_regclass until 9.4, the first commented query raises 42883 and this fallback silently drops foreign tables/materialized views from the sidebar instead of only omitting comments.
Useful? React with 👍 / 👎.
Summary
Surfaces database object comments in the UI (closes #1771):
A persisted preference (default on) gates the sidebar and grid display. Toggle from View > Show Object Comments. It is intentionally not in the Settings window.
Available for MySQL and PostgreSQL. Other engines simply show no comment.
Why
Column comments were already fetched end-to-end (
PluginColumnInfo.commenttoColumnInfo.comment) but dropped before reaching the grid. Table comments had no model field or fetch at all. This wires both through.Changes
PluginTableInfogainscommentvia a new init overload; the old init stays as@_disfavoredOverloadso already-built registry plugins keep loading. Additive, no PluginKit version bump.TableInfogainscomment, excluded from equality and hashing to preserve the sidebar selection-set invariant.fetchTablesreadsTABLE_COMMENTfrominformation_schema.TABLES(guards the view-comment quirk). PostgreSQLfetchTablesleft-joinspg_descriptionon every branch.ParsedSchemaMetadatatoTableRows.columnCommentstoNSTableColumn.headerToolTip.GeneralSettings.showObjectComments(default on) plus a View-menu toggle.Testing
Tests added:
TableInfocomment-ignores-identity,TableRows.columnComments,parseSchemaMetadatacomment extraction,PluginTableInfoCodable, PostgreSQLfetchTablesSQL.This machine has only Command Line Tools, so I could not build, run the test suite, run swiftlint, or run
scripts/check-pluginkit-abi.shlocally. Please build and run tests in Xcode. The PluginKit change is additive by the documented pattern; running the ABI script before release is still recommended.Docs updated: mysql and postgresql database pages. CHANGELOG entry added.
Fixes #1771