Skip to content

Phase 2.2: JSONB inline editing #26

Description

@aesslinger

Part of the Phase 2 set of PostgreSQL-specific features beyond the built-in driver.

Problem

JSONB columns are currently edited as a raw text string. For complex nested objects this is error-prone — a single misplaced brace or quote produces an opaque parse failure, and there's no way to modify one nested key without retyping the entire value.

Proposed approach

This is primarily a frontend feature (UI extension); the plugin's role is narrow:

  1. Detect JSONB columns and flag them in the get_columns response — already done (data_type: "jsonb").
  2. Validate JSON on update_record — return a clear error (with position) if invalid JSON is submitted, instead of a bare Postgres parse error.
  3. Optionally expose jsonb_set/jsonb_insert/jsonb_delete_path-style helper operations so the frontend can apply targeted edits.

Plugin-side additions

  • New RPC method: validate_jsonb(value) → returns ok, or a parse error with position.
  • New RPC method: jsonb_patch(params, table, pk, path, operation, value) → applies a targeted JSONB modification without overwriting the entire value.

Frontend integration

  • JSON tree editor component (expand/collapse nodes, edit values inline).
  • Add/remove key buttons.
  • Path breadcrumb showing current location in the JSON tree.
  • Raw mode toggle (switch between tree and text editor).

Security considerations

A jsonb_patch call with an incorrect path could corrupt data (e.g. overwriting the wrong nested key). The frontend should validate that the target path exists and show a preview of the resulting value before committing the patch.

Acceptance criteria

  • validate_jsonb rejects malformed JSON with a position-aware error, accepts valid JSON
  • jsonb_patch can add/remove/update a nested key without touching the rest of the document
  • Frontend tree editor can toggle to raw text mode and back without data loss
  • No regressions in existing Phase 1 parity tests

Tests

  • test_insert_complex_jsonb — nested objects, arrays, mixed types
  • test_update_jsonb_full_replace — overwrite entire value
  • test_jsonb_patch_add_key — add key to existing object
  • test_jsonb_patch_remove_key — remove key from object
  • test_jsonb_patch_nested_update — modify deeply nested value
  • test_invalid_jsonb_rejected — malformed JSON returns clear error

References

  • Full spec: docs/planning/03-phase-2-issue-16.md (2.2)
  • Priority: Sprint 2 — high demand, more complex (UI extension)
  • Required for the Phase 2 stable-release gate (CP-5)

Activity

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions