fix(row-editor): render decoded JSON/JSONB objects instead of [object Object]#475
Open
NewtTheWolf wants to merge 1 commit into
Open
fix(row-editor): render decoded JSON/JSONB objects instead of [object Object]#475NewtTheWolf wants to merge 1 commit into
NewtTheWolf wants to merge 1 commit into
Conversation
… Object] JSON/JSONB values from a query whose table name cannot be resolved (JOIN, DISTINCT, UNION, GROUP BY, aggregates) arrive decoded but without column metadata, so `type` is undefined and the JSON path never engages. They fell through to the raw textarea, where String(value) yields "[object Object]". A decoded object can only come from a JSON/JSONB column — dates and BLOBs cross the Tauri bridge as strings — so treat structured values as JSON regardless of type metadata, and keep the string heuristic behind the detectJsonInTextColumns setting. This lets the existing JsonInput take over, matching what the grid already renders via formatCellValue. Closes TabularisDB#428
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Reviewed by kimi-k2.6 · Input: 103.2K · Output: 7.1K · Cached: 77.9K |
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.
Closes #428
What was wrong
JSON/JSONB values shown in the Edit Row sidebar rendered as
[object Object]— but only for queries whose table name can't be resolved.The sidebar takes its column type from
columnMetadata, whichEditor.tsxonly fetches when a table name can be derived from the query.extractTableNamedeliberately bails onJOIN/DISTINCT/UNION/GROUP BY/ aggregates. No table name → nocolumnMetadata→typeisundefined→isJsonByTypeis false → the field falls through to the raw textarea, whereString(value ?? "")yields[object Object].The
detectJsonInTextColumnsfallback didn't catch it either:isJsonContentreturns false for anything that isn't a string, and the object check only coveredArray.isArray(value)— a plain object{...}matched neither.Opening the same table via the table browser always worked, which is why this is easy to miss.
The fix
A decoded object can only have come from a JSON/JSONB (or array) column — values cross the Tauri bridge as JSON, so dates and BLOBs arrive as strings (
isBlobWireFormatmatches a"BLOB:"string prefix). So structured values are now treated as JSON regardless of type metadata, while the string heuristic stays behind thedetectJsonInTextColumnssetting.This lets the existing
JsonInputtake over — Monaco editor and pretty-printing included — and matches what the grid already renders viaformatCellValue, which has had atypeof value === "object"branch all along.Note the issue proposed stringifying at the textarea. That would have shown readable JSON but kept the plain textarea instead of the JSON editor, and written the string back on save — so the fix sits one level up, at the decision of whether a value is JSON.
DataGrid.isJsonCellTargethad the identical gap (no JSON editor for untyped objects on inline cell edit). It's fixed via the same shared helper rather than patching each symptom separately.Testing
tests/utils/json.test.ts— regression coverage forisStructuredValue, including that BLOB/date string forms are rejectedReproduced manually on v0.13.4 against PostgreSQL
jsonb+jsoncolumns, using a self-join in the console so the table name can't be extracted:Manual re-verification of the fixed build is still outstanding — the reproduction above predates the fix, and this branch has since been rebased onto 0.15.0. Automated coverage coming from the unit tests only; a click-through of the Edit Row panel would be good before merge.