Skip to content

feat(plugin-mongodb): nested field paths, write options, and MQL formatting - #2105

Merged
datlechin merged 3 commits into
mainfrom
feat/2095-mongo-authoring-followups
Aug 13, 2026
Merged

feat(plugin-mongodb): nested field paths, write options, and MQL formatting#2105
datlechin merged 3 commits into
mainfrom
feat/2095-mongo-authoring-followups

Conversation

@datlechin

Copy link
Copy Markdown
Member

Follow-up to #2102, which shipped the language seam, MongoDB completion and the PostgreSQL operator vocabulary. This finishes the remaining MongoDB items from #2095.

Write options were silently dropped

db.users.updateOne({...}, {...}, {upsert: true}) parsed the first two arguments and threw the third away without a word, so an upsert quietly did nothing and the user was told the write succeeded. upsert, arrayFilters and hint now reach the server, and the result reports upsertedCount alongside modifiedCount.

The parser only emits the new .write case when an options argument is actually present. The plain two-argument forms keep producing .updateOne / .updateMany / .replaceOne / .findOneAndUpdate exactly as before, so an older MongoDB plugin binary running under a newer app keeps working on the syntax it already understood, and only meets an unknown case for syntax it never supported.

All four writes go through one runCommand path rather than threading mongoc opts through a single case, so findAndModify and the update command carry the same options uniformly.

Nested field paths

address.city never appeared in completion because unionColumns types a nested object as one opaque JSON column. That stays flat on purpose, since the grid renders it as one column; a separate fieldPaths walker reports the dotted paths instead: nested objects, objects inside arrays, up to a depth limit, with the majority BSON type per path and shallower paths ranked first.

It rides a new sampleFieldPaths requirement on PluginDatabaseDriver with a default of [], which is correct for every SQL driver and additive for ABI. Results are cached per collection with in-flight coalescing, and cleared on database switch and refresh, matching the schema-loading invariant.

No client checked ships this. DataGrip's equivalent request has been open eight years.

Format Query follows the editor language

QueryFormatterFactory keyed on the same EditorLanguage the completion seam uses. MongoShellFormatter lays documents out by nesting depth, keeps short ones inline, and never reformats inside a string literal. Cmd+Shift+F used to run the SQL tokenizer over MQL, which has no notion of {, : or object literals.

ABI

Additive, no currentPluginKitVersion bump. scripts/check-pluginkit-abi.sh reports a diff; normalizing the @_disfavoredOverload attribute away, the single removed line is re-added byte-identical and the rest are new declarations, so no symbol disappeared. Needs the abi-additive label.

Testing

22 new tests: 9 for nested field paths, 6 for write options, 7 already covering chained cursor methods. Suites green: MongoShellParser, MongoShellParserChainedMethod, BsonFieldPath, BsonDocumentFlattener, MongoContextAnalyzer, SQLFormatterService, SQLSchemaProvider. swiftlint lint --strict clean on the app scope and on the plugin and test files SwiftLint's included: TablePro scope skips.

The AllPlugins target builds. That matters here: MongoDB is registry-only, so PR CI does not compile it and a break in MongoDBPluginDriver would otherwise pass every check.

Still not done from #2095

  • Inline diagnostics. The editor is not an NSTextView, so setTemporaryAttributes and addRenderingAttribute are both unreachable. EmphasisManager.underline(color:) is the seam and needs no vendored change, but a gutter marker does, since GutterView has no per-line marker primitive.
  • Enum values from pg_enum in a comparison.

@mintlify

mintlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟡 Building Aug 13, 2026, 11:32 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin added the abi-additive PluginKit ABI diff reviewed as additive; no version bump needed label Aug 13, 2026
@datlechin
datlechin merged commit 1665429 into main Aug 13, 2026
4 checks passed
@datlechin
datlechin deleted the feat/2095-mongo-authoring-followups branch August 13, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

abi-additive PluginKit ABI diff reviewed as additive; no version bump needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant