fix(plugin-mongodb): make MQL exports and the query editor round-trip BSON values - #2090
Merged
Conversation
…gacy UUID strings
…ng the real binary subtype
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Follow-ups to #2089. Three commits, each standalone.
1. MQL export loses BSON binary values
MQLExportPluginhardcoded"subType": "00"on every binary cell. Investigating it turned up a bigger defect in the same line: the export writes{"$binary": {...}}, but the docs say the file is amongoshscript, and mongosh is a JavaScript REPL. It reads that as a plain object literal and inserts a subdocument with a$binarykey, not a BSON binary. Fixing only the subtype would have corrected a value inside a container that never worked.Both are now fixed together: binary exports as
BinData(<subtype>, "<base64>"), a real mongosh constructor.The subtype reaches the exporter with no PluginKit change.
PluginStreamHeaderalready carriescolumnTypeNamesandMQLExportPluginwas discarding it while holding the column index.BsonValueKind.binary(a MongoDB-plugin-internal enum) gained aUInt8payload, andtypeNamenow emitsBLOB(3)where it emittedBLOB.ColumnTypeClassifiersplits a type name at the first(and looks up the base, soBLOB(3)still classifies as.bloband nothing about the grid, the hex editor, the edit guard or copy changes.MongoDBUuidCodec.columnTypeName(forSubtype:)andbinarySubtype(fromColumnTypeName:)are the only places that spelling is written or read, and MQL export issupportedDatabaseTypeIds = ["MongoDB"], so it never sees another driver'sBLOB.This also reverses one thing #2089 got wrong: it taught MQL export to turn a UUID wrapper into
$binaryExtended JSON, which is the same mistake in the other direction. A wrapper now becomesBinData(...)too, so the output needs no particular mongosh version.2. The query editor rejects mongosh syntax
Copy
UUID("8cd003eb-…")out of the grid, paste it into a filter, get a parse error. libbson'sbson_new_from_jsonspeaks only Extended JSON, and TablePro supported no shell helper syntax at all:ObjectId(...),ISODate(...)andBinData(...)all failed the same way. #2089 made it visible by rendering text users would naturally paste.MongoShellValueTranslator(new, in PluginKit, pure) rewrites value constructors into Extended JSON.MongoShellParser.parseruns it once over the whole statement, so every payload is covered from one place: filter, update, replacement, documents, pipeline, index keys, sort, projection andrunCommand. That includes.sort({at: NumberInt(-1)}), which used to be dropped silently rather than reported.The scan is string-aware and rests on one rule: a method call is always preceded by a dot and a constructor never is. That separates
find(fromObjectId(, leaves a helper inside a string literal alone, and makes the pass idempotent, which matters becausebuildExplainQueryre-parses translated text.Supported:
ObjectId,ISODate,Date,NumberInt,NumberLong,NumberDecimal,Timestamp,BinData,HexData,MinKey,MaxKey,UUIDand the legacy UUID names, which route through the existing codec rather than re-deriving the byte orders. Malformed arguments throw an error naming the helper. An unknown constructor is passed through untouched for the driver to reject, and text carrying no helper short-circuits, so the translator never doubles as a JSON validator.Still not evaluated, and documented as such:
new Date(), arithmetic, and regex literals like/abc/i.3. Strings catalog
Java,C#andPythonare driver identifiers, and CLAUDE.md says not to localize technical terms, so they are plain literals now, matching theSCRAM-SHA-1/X.509/AWS IAMoptions in the same form.Legacy UUID EncodingandDo Not Decodeare added to the catalog as empty entries, the same shape as the 91 others awaiting translation. Verified thatConnection ModeandAuth Methodfrom the LibSQL and Trino plugins are present the same way, which is what confirmed the app-side mirror is what gets a key extracted.Verification
TableProTeststarget with CI's own quarantine skip list.AllPluginsbuilds. This matters more than usual: see below.Worth knowing: PR CI does not compile registry-only plugins
While working on this I introduced a hard compile error in
BsonDocumentFlattener.swiftand the app build still reported success.macos-tests.ymlbuilds-scheme TablePro, whose dependencies are the 14 bundled plugins; MongoDB and the other 15 registry plugins are only compiled by theAllPluginsaggregate, which nothing in PR CI runs.build-plugin.ymlonly fires onplugin-*-v*tags.So a change confined to a registry plugin can pass CI while being broken. My error happened to be caught because
BsonDocumentFlattener.swiftis in the test target's source list, but the rest of the MongoDB plugin is not compiled by CI at all. Adding anAllPluginsbuild step tomacos-tests.ymlwould close it. I have not done that here since it is a CI change beyond these follow-ups.Not included
unwrapExtendedJsonmaps$oidto aStringand the type is gone by export time. Same class of bug as the binary subtype was, and it needs the same boxing treatment. Its own change.https://claude.ai/code/session_01628orR3jwc3ATfcFCLVUMB