Skip to content

fix(row-editor): render decoded JSON/JSONB objects instead of [object Object]#475

Open
NewtTheWolf wants to merge 1 commit into
TabularisDB:mainfrom
NewtTheWolf:fix/428-jsonb-object-row-editor
Open

fix(row-editor): render decoded JSON/JSONB objects instead of [object Object]#475
NewtTheWolf wants to merge 1 commit into
TabularisDB:mainfrom
NewtTheWolf:fix/428-jsonb-object-row-editor

Conversation

@NewtTheWolf

@NewtTheWolf NewtTheWolf commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

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, which Editor.tsx only fetches when a table name can be derived from the query. extractTableName deliberately bails on JOIN / DISTINCT / UNION / GROUP BY / aggregates. No table name → no columnMetadatatype is undefinedisJsonByType is false → the field falls through to the raw textarea, where String(value ?? "") yields [object Object].

The detectJsonInTextColumns fallback didn't catch it either: isJsonContent returns false for anything that isn't a string, and the object check only covered Array.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 (isBlobWireFormat matches a "BLOB:" string prefix). So structured values are now treated as JSON regardless of type metadata, while the string heuristic stays behind the detectJsonInTextColumns setting.

This lets the existing JsonInput take over — Monaco editor and pretty-printing included — and matches what the grid already renders via formatCellValue, which has had a typeof 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.isJsonCellTarget had 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 for isStructuredValue, including that BLOB/date string forms are rejected
  • Full suite green (2839 tests), typecheck and lint clean

Reproduced manually on v0.13.4 against PostgreSQL jsonb + json columns, using a self-join in the console so the table name can't be extracted:

SELECT a.id, a.label, a.payload, a.meta FROM t a JOIN t b ON a.id = b.id;

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.

… 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
@kilo-code-bot

kilo-code-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • src/components/ui/DataGrid.tsx
  • src/components/ui/FieldEditor.tsx
  • src/utils/json.ts
  • tests/utils/json.test.ts

Reviewed by kimi-k2.6 · Input: 103.2K · Output: 7.1K · Cached: 77.9K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PostgreSQL JSONB column rendering as [object object] on sidebar editor

1 participant