feat(editor): language-aware query authoring for MongoDB and PostgreSQL - #2102
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 was referenced Aug 13, 2026
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.
Closes #2095 (all but the two items under "Not in this PR").
Query authoring was SQL-only.
SQLCompletionAdapterhardcoded the SQL engine and never readPluginManager.editorLanguage(for:), so MongoDB went through the SQL pipeline. The issue says the MQL dot path returns an empty list. It is worse than that:SQLContextAnalyzernever matches a SQL clause on JavaScript text, so everything fell through to.unknownand the popup offeredSELECT,INSERTand collection names insidedb.users.find({...}).The fix is a language seam rather than a special case, because no SQL clause vocabulary can describe
db.orders.aggregate([{$match: ...}]).Wrong results, fixed
db.orders.aggregate([...]).limit(10)silently dropped the.limit(10). The chained-options parser was gated oncase .find, so every non-find operation discarded its chain with no error. The driver's only backstop isPluginRowLimits.emergencyMax, so that query could return up to 5,000,000 documents instead of 10.Chained cursor methods now translate into pipeline stages (
$sort,$skip,$limit, in cursor order), which needs no change toMongoOperation.aggregateand so no ABI break. Unknown chained methods and chaining onto a call that returns no cursor now throw instead of being dropped.Language routing
QueryCompletionServiceis resolved fromEditorLanguage, which was already plumbed and already drives six other behaviour branches..sqlroutes to the existing engine unchanged, so the 30 SQL-family plugins are untouched..javascriptroutes to the new MQL service.The adapter is now
QueryCompletionAdapterand owns only debounce, session, insertion and the delegate conformance. SQL-specific empty-prefix suppression moved intoSQLCompletionServicewhere it belongs, and window extraction moved into the services, which collapses three overlapping windowing layers (adapter,CompletionEngine,SQLContextAnalyzer) into one.MongoDB completion
MongoContextAnalyzeris a structural bracket-frame scanner overNSString, not a regex. It classifies eleven positions and tracks string literals, escapes and both comment forms, so a brace inside a string does not open a document.The operator sets are deliberately separate. Offering
$matchinside a filter, or$gtewhere a stage belongs, is worse than offering nothing, and$set/$unsetmean different things as update operators and as pipeline stages.db.db.users.$$variables,$fieldpathsField names come from the sampled document schema the sidebar already builds. Nothing in the buffer is evaluated to produce a list, which is deliberate: MONGOSH-2635 is a mongosh bug where Tab-completion ran a property getter and deleted a collection.
PostgreSQL
SQLDialectDescriptorgainsoperators: [SQLOperatorDescriptor]with per-operator summary, category and applicable types. PostgreSQL declares 60, correctly scoped so the jsonb-only operators (@>,?,?|,?&,@?,@@) are not offered as ifjsonaccepted them.Keywords go from 84 to about 500 including 130 multi-word constructs, functions from 43 to about 400, data types from 28 to about 90.
SQLContextAnalyzerlearns::, which becomes a new.castTargetclause offering type names in the spelling people write. pgAdmin is the only client that completes casts and it leaks catalog spellings such asint4andbpchar.Corrections the research turned up and the data reflects:
random_normalanderfare PG16, not 17.uuidv4/uuidv7are PG18, not 17, whileuuid_extract_timestampis 17.regexp_countand friends are PG15.@@@is not a PG17 operator.ABI
Additive, no
currentPluginKitVersionbump. The existing 14-parameter init keeps its exact signature and gains only@_disfavoredOverload, which is compile-time and does not change the mangled symbol; a new 15-parameter init is favored.withCaseSensitivityStyleforwardsoperatorsexplicitly, which it would otherwise have silently dropped.scripts/check-pluginkit-abi.sh mainreports a diff. Normalizing the attribute away, the one removed line is re-added byte-identical and the other 91 lines are new declarations, so no symbol disappeared. This PR needs theabi-additivelabel.Testing
46 new tests: 24 for
MongoContextAnalyzer, 13 for chained cursor methods and write options, 9 for nested field paths.swiftlint lint --strictis clean on the app scope (1333 files) and on the plugin and test files that SwiftLint'sincluded: TableProscope skips by default. Suites run green: MongoShellParser, MongoShellParserChainedMethod, MongoContextAnalyzer, BsonFieldPath, BsonDocumentFlattener, SQLContextAnalyzer, SQLDialectDescriptor, SQLFormatterService, CompletionEngine, SQLSchemaProvider, QueryCompletionAdapterLifecycle.The
AllPluginstarget builds, which matters here: MongoDB is registry-only, so PR CI does not compile it and a break inMongoDBPluginDriverwould otherwise pass every check.No UI automation. The completion popup is a
nonactivatingPaneldriven by a 50 ms debounce, which is not deterministic under XCUITest; the position logic it depends on is covered by the analyzer unit tests instead.Also in this PR
Nested MongoDB field paths.
unionColumnsstays flat because the grid renders a nested object as one JSON column, so a separatefieldPathswalker reports dotted paths:address,address.city,address.zip, and paths inside objects an array holds. It rides a newsampleFieldPathsdriver requirement with a default of[], which is correct for every SQL driver and additive for ABI. Cached per collection with in-flight coalescing, cleared on database switch and refresh. No client checked ships this.Write options.
db.users.updateOne({...}, {...}, {upsert: true})used to drop the third argument silently, so an upsert quietly did nothing.upsert,arrayFiltersandhintnow reach the server, and the result reportsupsertedCountalongsidemodifiedCount. The parser only emits the new.writecase when an options argument is present, so an older MongoDB plugin binary keeps working on the two-argument forms it already understood.Language-routed formatting.
QueryFormatterFactorykeyed on the sameEditorLanguage.MongoShellFormatterlays documents out by nesting depth, keeping short ones inline, and never reformats inside a string literal. Cmd+Shift+F used to run the SQL tokenizer over MQL.Not in this PR
Named so they are not mistaken for done:
NSTextView:CodeEditTextView.TextViewis anNSViewwith a hand-rolledNSTextInputClientand its own layout manager, 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. Worth knowing: TextKit 2 rendering attributes silently ignoreunderlineStyle, verified by pixel-diff and documented nowhere.pg_enumin a comparison. Unclaimed by every client checked, and cheap.Related
TextViewController+Lifecycle.swift:327triggers completion with nohasMarkedText()guard, and the vendoredCodeSuggestionmodule has no marked-text awareness at all, while the apply path is guarded. That is a CJK composition bug independent of this issue.QueryCompletionAdapternow guards both its trigger and apply paths; the vendored gap remains.