Conversation
…by their stored _id and saved under an exact guard
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
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 the rest of #3132: you can now add, rename or remove a field in a MongoDB document. Follows #3140 (Insert Document).
Root cause
The grid kept only a row's display text, not its BSON identity:
_idhad its keys re-sortedPluginQueryResultalso had no per-row channel for anything else. So an edit had to guess the stored value from text, and the earlier attempt (448d9047e) reached the wrong document, or none:_idof another typeIts guard was a plain match, and a match is not equality:
nullmatches a missing field,5matches[5, 6], and int32 5 matches int64 5. Its$setdiff also could not keep the order the fields were written in, and it read a dotted name as a path.Fix
Identity travels with the row. A find with no projection now tags each row with the compact canonical Extended JSON of its stored
_id. The tag is read from the same libbson text the row comes from.PluginQueryResult.rowLocators, an optional stored property set after construction (additive; the kit stays 33). From there it goes toQueryResult,QueryFetchResultandTableRows, keyed byRowID.Fetch (
fetchDocument, a new requirement with a default):_idvalue, never an operator._idunique. So is any collection type the driver does not know, and any server older than 4.0._iduses its index. It carriesmaxTimeMSand runs under a cancellable lease.limit. It skips documents whose_idonly collates equal and stops at the second exact match. On a sharded collection each shard can return its own lenient match, and those can no longer use up a count._idbytes equal the locator counts.$field, or a repeated fieldTimestamp(0, 0)Save is a whole-document
replaceOneunder the simple collation._idgoes first, then the fields in the order written._idcannot change.{_id, $expr: {$and: [$$ROOT == original, typeSignature == expected]}}. The signature holds one$mapper nesting level, so its size grows with depth, not length.1equalsNumberLong(1)inside a scope.matchedCount0 reports "changed on the server" and keeps the user's text.Menus. Entry points are Edit > Edit Document… and the row's context menu. Edit Document and Insert Document dim in Agent mode through the same set that dims Add Row.
Guard check.
scripts/check-mongodb-document-guard.shbuilds filters with the guard's own sources and asks a live mongod about them. It also asserts that the guard refuses NaN and code with a scope.Verified
limit: 2applied before exact_idmatching, time-series collections not refused, and Edit Document still enabled in Agent mode. All five were fixed before round 2.any PluginDatabaseDriver, which is howPluginDriverAdaptercalls it, the fetch already ran off the main thread, so the app did not freeze. What the probe did was block a cooperative-pool thread inqueue.sync. A direct call from the main actor ranbuildInfoon the main thread. After the fix it runs on the connection's queue.CancellationErrorand sends nothing.abcwithABCstored reads as gone, andABCopens.MainMenuValidationTestsandStringCatalogIntegrityTests). With the between-step cancel checks removed,cancelStopsTheNextStepfails (18 run, 1 failed).AllPlugins(40).cec9b57c5: 4 additions, none removed. The kit stays 33 (v0.75.0 ships 32).mainatc21dc512ewith no conflicts, then rerun: MongoDBDriver and the app build, 106/106 in the 13 suites this branch changes, 0 lint violations, plugin localization check clean.Deliberately not fixed here
buildInfoorlistCollectionsstops the read after that step, not inside it. Neither command runs in a sessionkillSessionscan reach, andbuildInfocarries nomaxTimeMS. The find, the only step that can scan, runs in a session that can be killed._iduniqueness._idscans the collection. The query timeout cannot bound that scan: libmongoc 1.28.1 putsmaxTimeMSinsideupdates.0, where the server refuses it (40415). This is documented under Limitations."", becauseinsert_oneruns libmongoc's default validation.MongoScriptFindShape.returnsWholeDocuments(fix(plugin-mongodb): create collections from New Table with their fields as a validator, read the fields back, and write values in their declared types #3145) andMongoScriptCursor.returnsWholeDocumentshere spell the same predicate twice. Make one read the other when this rebases.No UI test: CI has no MongoDB server, so the flow cannot run deterministically. The Agent-mode rule is covered by a unit test on the menu validator, and the cancellation order by unit tests on the read's steps.