Skip to content

feat(postgres): support editing hstore columns - #427

Merged
NewtTheWolf merged 5 commits into
TabularisDB:mainfrom
arturbent0:feat/postgres-hstore-support
Aug 2, 2026
Merged

feat(postgres): support editing hstore columns#427
NewtTheWolf merged 5 commits into
TabularisDB:mainfrom
arturbent0:feat/postgres-hstore-support

Conversation

@arturbent0

Copy link
Copy Markdown
Contributor

Reading hstore columns already worked (tokio-postgres decodes them natively as HashMap<String, Option>), but writing back failed with 'Cannot bind a JSON object to a non-JSON column' because hstore has no fixed OID and information_schema reports it generically as 'USER-DEFINED'.

  • Resolve the real hstore OID per column via pg_type before binding, since it varies per installation/schema.
  • Bind JSON objects (and, for now, JSON-encoded strings, the plain text cell editor doesn't yet distinguish hstore from other types) as HashMap<String, Option>, which tokio-postgres encodes natively as hstore.
  • Expose udt_name on TableColumn so the frontend can identify hstore precisely; data_type alone can't, since it's shared with every other extension/custom type.
  • Route hstore columns through the existing JSON editor in the row editor sidebar, and fix the inline cell editor to show valid JSON instead of '[object Object]' for any object-valued cell.

Closes #395

Reading hstore columns already worked (tokio-postgres decodes them
natively as HashMap<String, Option<String>>), but writing back failed
with 'Cannot bind a JSON object to a non-JSON column' because hstore
has no fixed OID and information_schema reports it generically as
'USER-DEFINED'.

- Resolve the real hstore OID per column via pg_type before binding,
  since it varies per installation/schema.
- Bind JSON objects (and, for now, JSON-encoded strings, the plain
  text cell editor doesn't yet distinguish hstore from other types)
  as HashMap<String, Option<String>>, which tokio-postgres encodes
  natively as hstore.
- Expose udt_name on TableColumn so the frontend can identify hstore
  precisely; data_type alone can't, since it's shared with every
  other extension/custom type.
- Route hstore columns through the existing JSON editor in the row
  editor sidebar, and fix the inline cell editor to show valid JSON
  instead of '[object Object]' for any object-valued cell.

Closes TabularisDB#395

@NewtTheWolf NewtTheWolf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this — resolving the per-install OID via pg_type and leaning on tokio-postgres's native HashMap encoding is the right approach, and the binding-layer test coverage is solid. 🙏

One blocking correctness issue inline: the USER-DEFINED fallback in the bind routing regresses editing of other user-defined types (enums, citext, PostGIS…). Fix + a note on the affected test are inline.

Non-blocking, your call:

  • bind_pg_hstore duplicates the oid-resolve → hstore_map_from_json_objectType::newBoundValue block across the Object and String arms — could fold into a small local closure.
  • get_hstore_oid_for_column fires one catalog query per USER-DEFINED column per row in the insert_record loop — fine for single-row edits, worth caching if bulk insert ever routes through here.
  • Type::new(..., "public") hardcodes the schema; harmless since prepare_typed pins on the OID, just noting hstore can live in another schema.

Also: the branch currently has a merge conflict against main (mergeStateStatus: DIRTY) — could you rebase/resolve that when you get a chance? 🙏

Comment thread src-tauri/src/drivers/postgres/binding.rs Outdated
Comment thread src-tauri/src/drivers/postgres/binding.rs Outdated
…folding from TabularisDB#450

data_type now reports the real udt_name for user-defined types, so:
- gate hstore OID resolution on data_type == "hstore" instead of "USER-DEFINED"
- route bind_pg_value by column_type == "hstore" so the unresolved-OID error stays reachable
- drop the now-redundant udt_name field from TableColumn and the frontend types
- port the row editor change to the type-based isHstoreColumn check (RowEditorSidebar was replaced by RowEditorPanel in TabularisDB#510)
@NewtTheWolf
NewtTheWolf merged commit fcee3d5 into TabularisDB:main Aug 2, 2026
1 check passed
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.

[Feat]: Add support for HSTORE type (postgresql)

2 participants