Add JSON columns content highlighting - #347
Open
danvergara wants to merge 4 commits into
Open
Conversation
rkgarcia
reviewed
Aug 12, 2026
| return dbTypeName == "JSON" || dbTypeName == "CLOB" || dbTypeName == "BLOB" || dbTypeName == "VARCHAR2" | ||
| case drivers.SQLServer: | ||
| // SQL Server lacks a native JSON type, so we must allow text. | ||
| return dbTypeName == "NVARCHAR" || dbTypeName == "VARCHAR" || dbTypeName == "TEXT" |
Collaborator
There was a problem hiding this comment.
Consider "SQL Server 2025 introduces a native JSON data type, shifting away from the older requirement of storing JSON documents as standard VARCHAR or NVARCHAR strings. Instead of treating JSON as a string, SQL Server 2025 parses it upon input and stores it internally in an optimized, native binary UTF-8 format (referred to as the MSJSON format)"
rkgarcia
reviewed
Aug 12, 2026
rkgarcia
left a comment
Collaborator
There was a problem hiding this comment.
Only review the MSSQL Json Data Type
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.
JSON column viewer with syntax highlighting
Description
Adds a way to inspect JSON columns as pretty-printed, syntax-highlighted documents instead of squeezing them into a single table cell.
Appending
| jsonto a read query switches the result panel from the usual table view to a text panel that pretty-prints the JSON payload and colorizes it with chroma.Also included: errors rendered into text panels are now styled (red, bold, padded) instead of being printed as plain text.
Changes
pkg/client/client.goQueryTypetype withNormalQuery/JSONQueryvalues, plus aJSONSuffix(| json) constant.QueryResultgains two fields:QueryTypeandJSONData []byte.trimJSONSuffix(query string) (string, bool)helper: reports whether a query requests the JSON view and returns the query with the suffix removed. Matching is case-insensitive (strings.EqualFold) and tolerant of surrounding whitespace, so| json,| JSON,| Jsonand| jsonare all recognized. Keeping this as a standalone function makes the parsing unit-testable without a database.AsyncQuerycalls the helper on the read path, executes the stripped statement, and marks the result as a JSON query.QueryResult.Querykeeps the original text including the suffix, so query history still shows what the user typed.no data returned.Client.isValidJSONColumnhelper maps drivers to acceptable column types:JSON,JSONB,TEXT,VARCHARJSONJSON,CLOB,BLOB,VARCHAR2NVARCHAR,VARCHAR,TEXT(no native JSON type)json.Indentacts as the final validatorJSON,JSONB[]byte→stringconversion, etc.) is unchanged; it now lives under thedefaultbranch of aswitchalongside the JSON branch.query(the goroutine's parameter, i.e. the suffix-stripped statement) instead of theqrange variable. This is load-bearing rather than cosmetic: without it the| jsonsuffix would reach the driver and every JSON query would fail with a syntax error.pkg/bubbletui/resultset.godblab-cyberpunkchroma style matching the app's palette: magenta keys, neon-green strings, purple numbers and literals, light-grey punctuation, red errors.qr.QueryType:JSONQuery→json.Indentthe raw bytes, highlight them withquick.Highlight(..., "json", "terminal256", dblab-cyberpunk), and render into a text panel.NormalQuery→ the existing table panel.errorStylebefore being set on the panel.pkg/client/client_test.goSeven cases added to
ClientTestSuite, all driver-parameterized throughDB_DRIVERlike the rest of the suite. They rely on ajsonExprhelper that builds a driver-specific expression yielding a JSON-typed column (::jsonbon Postgres,CAST(... AS JSON)on MySQL, a plain literal on SQLite), so no schema change is required to exercise the feature.TestAsyncQueryJSONViewQueryretains the suffix for historyTestAsyncQueryJSONViewSuffixVariantstrimJSONSuffixTestAsyncQueryJSONViewMultipleColumnsTestAsyncQueryJSONViewNonJSONColumnisValidJSONColumnrejection (skipped on SQLite, which accepts any type)TestAsyncQueryJSONViewNoRowsTestAsyncQueryWithoutJSONSuffixNormalQuerypath is unaffectedTestAsyncQueryJSONViewMixedBatchQueryTyperouting when JSON and normal queries run concurrentlyPayloads are compared after
json.Unmarshalrather than byte-for-byte, sincejsonbreorders keys and MySQL compacts whitespace.go.mod/go.sumgithub.com/alecthomas/chroma/v2 v2.27.0(and itsgithub.com/dlclark/regexp2/v2indirect dependency).Fixes #251
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
The suite requires Docker (testcontainers):
Both drivers pass.
Manual check in the TUI — no schema needed, this one literal exercises every token type in the style at once:
Verify:
true/nullpurple, punctuation grey;no data returned;Checklist: