Skip to content

feat: [WIP] BSON Extended JSON and filter/sort query documents - #15

Draft
vinimcorrea wants to merge 2 commits into
TabularisDB:mainfrom
vinimcorrea:feat/bson-filter-sort
Draft

vinimcorrea wants to merge 2 commits into
TabularisDB:mainfrom
vinimcorrea:feat/bson-filter-sort

Conversation

@vinimcorrea

Copy link
Copy Markdown
Contributor

Summary

Refs TabularisDB/tabularis#1531. Host side: TabularisDB/tabularis#1766.

Draft / WIP, opened as agreed in TabularisDB/tabularis#1531.

Two changes the host's Documents view and Filter/Sort bar need from this plugin:

  1. BSON values as Extended JSON. Results send BSON types (ObjectId, dates, Long, Decimal128, binary, ...) as MongoDB Extended JSON instead of flattening them to plain strings, so the host can show them as typed values. Values coming back from the host are read the same way, so edits keep the BSON type.
  2. Filter and sort as query documents. The host sends the Filter and Sort fields as typed. The plugin parses them as relaxed JSON (json5: unquoted keys, single quotes, trailing commas) with Extended JSON values, and applies them to the find.

Validation

  • cargo test: 78 passed.
  • Checked end to end with the host branch against a replica set through the SSH SOCKS5 tunnel.

Known limit

Missing fields vs. stored nulls is left for a follow-up, as agreed in TabularisDB/tabularis#1531.

bson_to_json emitted ObjectId as hex, dates as epoch milliseconds and
binary as the string "Binary(N bytes)". Send ObjectId, dates, UUIDs
(binary subtype 4, as $uuid), other binary, decimals, timestamps and
regular expressions as relaxed Extended JSON, and decode the same
wrappers in json_to_bson so a tagged _id still locates its record.
Date edits accept ISO 8601 text as well as epoch milliseconds.
A table tab's WHERE and ORDER BY were dropped: only the collection name
was read from the host's SELECT, so a filter silently showed unfiltered
data. WHERE and ORDER BY now carry query documents
(WHERE { status: 'active' } ORDER BY { _id: -1 }), read with the Mongo
shell syntax: unquoted keys, single quotes, ObjectId(), UUID(),
ISODate(), regex literals. Input that is not a query document is an
error with an example, not ignored. The same parser serves find() and
aggregate() arguments, and the host's row-count wrapper counts with the
filter.
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.

1 participant