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
Merged
Conversation
…lds as a validator, read the fields back, and write values in their declared types
… cancellation intact on the new write and schema paths
…add the new refusals to the string catalog
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…ds, and type date and bool _id filters
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
…te-collection # Conflicts: # TablePro/Resources/Localizable.xcstrings # TableProTests/Core/Menu/MainMenuBuilderTests.swift # docs/databases/mongodb.mdx
This was referenced Sep 26, 2026
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.
Fixes #3131
Root cause
generateCreateTableSQLorgenerateAddIndexSQL, so the Create Table composer readnilas "This database cannot create a table from the visual editor." and dimmed Create Table.$jsonSchemavalidator._idand nothing else: the reporter's step 3.What changed
MongoDB plugin (registry-only)
MongoDBCollectionDDLturns the draft intodb.createCollection("articles", {"validator": {"$jsonSchema": …}}).required; nullable fields also acceptnull.strict/errordefaults stay in force._idis created without a validator.createIndexwith the keys in order. BTREE→1, HASH→hashed, FULLTEXT→text, SPATIAL→2dsphere.ObjectIdworks)_id(the reporter'sidrow)_idtyped other thanobjectId$, dotted, integer-like and__proto__field names_idaloneMongoDBCollectionSchemaparses the validator fromlistCollections, keeping declared order. Two readers use it:fetchColumnsmerges the declared fields in, reusing the call it already made for enums.listCollectionsfalls back to sampling; a Stop propagates.$date, including the picker's local-time text$oidintin canonical decimal, because a bare010is octal 8 in JavaScriptCore$numberLong_idby a kind only when every sampled_idshares it{…}/[…]text is pasted in only when it is strict JSON. Before, a stored[db.getCollection("audit").drop()]ran when its row was duplicated or its delete undone.MongoScriptJson's scanner now work scalar by scalar. A Unicode Prepend character (U+0600) fused with the"after it into oneCharacter, which went out unescaped and closed the string literal.MongoCollectionAccessorwritesdb.<name>only for ASCII identifiers. A U+0D4E letter joined to(passedisLetter.App
CreateTableEligibilityasks the live driver for its form spec or a one-columngenerateCreateTableSQLprobe, the same shape asDatabaseObjectToolEligibility. No PluginKit change.defaultPrimaryKeyColumn).Before / After
Before, from the report. Every row gets the same dead-end message, and Create Table is dimmed:
After, with the reporter's first row as typed: the refusal names the field and says what to do:
After, with
_idand four fields. SQL Preview shows the collection and its validator:After Create Table, the new, empty collection shows its declared fields:
Structure shows the declared types, with
titleNOT NULL:Verification
verify.sh teston the rebased branch, 28 suites. New suites:MongoDBCollectionDDLTests: statement text, refusals, index mapping and key orderMongoDBCollectionSchemaTests: parse order, escaped and Prepend keys, enumsCreateTableEligibilityTests: stub driversMongoDBWriteBackTypeTests,MongoScriptPreludeTests(the generated statements run through the real prelude in JavaScriptCore),MongoDBQueryBuilderTests,BsonDocumentFlattenerTests,CreateTableDraftBuilderTests,MainMenuValidationTestsandDatabaseTreeMenuSpecTestsverify.sh buildfor the app andMongoDBDriverboth pass on the rebased branch.swiftlint lint --strictover every changed file shows no new findings.check-writing-style.shandcheck-docs-against-source.pyboth pass.swiftcharness over the realMongoDBPluginDriver, against mongo:7.0:fetchColumnsand the empty browse return the declared fieldsdate,double,int,array,stringandlong, and9007199254740993is not rounded121 Document failed validation, which relies on fix(plugin-mongodb): report shell errors and rejected writes instead of an empty success #3139insertQuotesInt64Overflowexpected9223372036854775807bare. JavaScriptCore reads that literal as9223372036854776000(measured withjsc), so it now crosses as$numberLong.Reviewed by Codex. Every finding from both passes was fixed or is noted here, along with a separate security review. One finding is left for its own PR: PluginKit's default
escapedParameterValuehas the same per-Characterescaping bug for SQL literals.Notes
plugin-mongodbtag. The app half (the New Table gate, name-only creates, preview highlighting) ships with the next app release.Adversarial review
The Codex adversarial pass returned four findings.
JSONSerializationrefuses{}, injected: db.dropDatabase(), tail: {}and each variant tried, so none reaches the statement as source.jsonPrefixWithTrailingCodeIsAStringpins that for update and restore.listCollectionsnow carriesmaxTimeMS: 5000._idof different BSON types on one page (high): already true before this change, not fixed here. A page holding both"1001"and1001still falls back to reading the text. The fix is carrying each row's canonical_idthroughPluginRowChange, and the Can't create,edit or remove properties from MongoDB database. Why?????? #3132 work is taking it on. A page whose_ids share one kind now uses that kind, anddateandbool_idfilters are typed.$unset(high): already true before this change, not fixed here. It lives ingenerateUpdate/generateInsert, which the Can't create,edit or remove properties from MongoDB database. Why?????? #3132 grid-serializer PR rewrites.