Add Full Support for Views Listing and Definitions#312
Open
danvergara wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Full Support for Views Listing and Definitions
Description
This PR adds comprehensive support for listing database views and displaying their definitions across all supported database drivers (PostgreSQL, MySQL, SQLite, Oracle, and SQL Server).
Previously, dblab only displayed tables in the sidebar catalog. With this change, views are now listed alongside tables (visually distinguished with a
vsuffix) and selecting a view shows its definition and column data in the result panel.Changes
Core Client (
pkg/client/)ViewRefstruct — mirrorsTableReffor referencing views with schema-qualified names.EntityNamefield onDBNode— separates the display name (with type suffix) from the actual entity name used in queries.databaseQueriermethodGetViewDefinition— each driver implements this to retrieve the DDL/definition of a view.ViewMetadatamethod onClient— fetches both the view definition and its content (rows).viewContentmethod — queries the view data with pagination support across all drivers.[]bytehandling inQuery— properly distinguishes BLOB/BYTEA columns from text columns returned as[]byte, preventing raw binary output.Driver Implementations
postgres.go): Queriespg_classfor views/materialized views (relkind IN ('v','m')). Usespg_get_viewdef()for definitions.mysql.go): Queriesinformation_schema.VIEWS. UsesSHOW CREATE VIEWfor definitions.sqlite.go): Queriessqlite_master WHERE type='view'. Retrieves thesqlcolumn for definitions.oracle.go): QueriesALL_VIEWSfiltered by owner/schema. Retrieves theTEXTcolumn for definitions.mssql.go): Queriessys.viewsjoined withsys.schemas. UsesOBJECT_DEFINITION()for view DDL. Also adds schema handling that was previously missing.TUI (
pkg/bubbletui/)selectViewMsg— message type for view selection events in the sidebar.MetadataPanelinterface withTablePanelandTextPanelimplementations — allows the result set to display either tabular data or plain text (for view definitions).ResultSet— dynamically switches between table-mode tabs (Data,Columns,Indexes,Constraints) and view-mode tabs (Definition,Columns) depending on selection.Supported Databases
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Locally, against containers running the Pagila, Sakila and Chinook databases.
Checklist: