feat(plugin-mongodb): nested field paths, write options, and MQL formatting - #2105
Merged
Conversation
|
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-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,arrayFiltersandhintnow reach the server, and the result reportsupsertedCountalongsidemodifiedCount.The parser only emits the new
.writecase when an options argument is actually present. The plain two-argument forms keep producing.updateOne/.updateMany/.replaceOne/.findOneAndUpdateexactly 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
runCommandpath rather than threadingmongocopts through a single case, sofindAndModifyand theupdatecommand carry the same options uniformly.Nested field paths
address.citynever appeared in completion becauseunionColumnstypes a nested object as one opaqueJSONcolumn. That stays flat on purpose, since the grid renders it as one column; a separatefieldPathswalker 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
sampleFieldPathsrequirement onPluginDatabaseDriverwith 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
QueryFormatterFactorykeyed on the sameEditorLanguagethe completion seam uses.MongoShellFormatterlays 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
currentPluginKitVersionbump.scripts/check-pluginkit-abi.shreports a diff; normalizing the@_disfavoredOverloadattribute away, the single removed line is re-added byte-identical and the rest are new declarations, so no symbol disappeared. Needs theabi-additivelabel.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 --strictclean on the app scope and on the plugin and test files SwiftLint'sincluded: TableProscope skips.The
AllPluginstarget builds. That matters here: MongoDB is registry-only, so PR CI does not compile it and a break inMongoDBPluginDriverwould otherwise pass every check.Still not done from #2095
NSTextView, sosetTemporaryAttributesandaddRenderingAttributeare both unreachable.EmphasisManager.underline(color:)is the seam and needs no vendored change, but a gutter marker does, sinceGutterViewhas no per-line marker primitive.pg_enumin a comparison.