Skip to content

fix(connections): MongoDB restore into a renamed database restores nothing and reports success - #3222

Open
datlechin wants to merge 6 commits into
mainfrom
fix/mongodb-backup-restore-arguments
Open

datlechin wants to merge 6 commits into
mainfrom
fix/mongodb-backup-restore-arguments

Conversation

@datlechin

@datlechin datlechin commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • MongoDB restore into a database with a different name restored nothing and reported success. mongorestore got --nsInclude=<target>.*, which matches the <source>.* namespaces stored in the archive, so every collection was filtered out and the tool still exited 0; it now gets --nsFrom=$db$.$coll$ --nsTo=<target>.$coll$.
  • MongoDB Backup Dump and Restore ignored the connection's Auth Database, Hosts list, replica set, SRV and TLS options. The tools got their own --host, --port, --authenticationDatabase and --ssl flags with their own auth database rule instead of the connection the driver uses; they now get one connection string, built with the driver's rule, in the 0600 config file next to the password.
  • The Restore confirmation said existing objects are overwritten on every engine. The text was one constant that is only true of mysqldump, while pg_restore, mongorestore and sqlite3 keep existing objects, DuckDB stops at the first one and sqlpackage needs an empty database; each dump descriptor now declares what its restore does.

Tests

  • NativeDumpRegistryTests.mongoScopesItsDatabase: spec change, the old assertion expected --nsInclude=sales.* and encoded the defect. Fails without the fix. mongoRestoreTargetIsLiteral (new) pins that * in the target stays literal.
  • NativeDumpRegistryTests.mongoAuthenticatesAgainstTheAuthDatabase, mongoSrvUsesAConnectionString(kind:), mongoHostListUsesAConnectionString and mongoRequiredSkipsVerification (new), plus mongoSkipsCredentialsWithoutUser and emptyHostFallsBackToLoopback (spec changes, the connection moved from argv into the config file). All six fail without the fix.
  • MongoToolsConnectionStringTests (new, 11 cases): auth database parity with the driver's MongoDBAuthSourceResolver for every combination, SRV detection and port stripping, host list ports and IPv6, username encoding, connection options, extra URI parameters and each TLS mode. The type it tests is new, so it does not build without the fix.
  • RestoreConfirmationTextTests (new, 6 cases): only MySQL and MariaDB say objects are overwritten, the appending engines say they are kept, DuckDB says it stops in both formats, SQL Server says it needs an empty database. Four of the six fail without the fix.
  • No UI test: the confirmation needs a live server and the engine's restore tool, which CI does not have. RestoreConfirmationTextTests covers the text the flow shows.

Docs

The docs rewrite branch covers the user-facing text: docs/features/backup-restore.mdx (the --nsInclude sentence and "Objects it names are overwritten") and docs/databases/mongodb.mdx (Auth Database).

CI fixes

The failed package test was SyncRecordMapperTests.unknownWireValueFailsClosed. The mapper's duplicate Safe Mode decoder turned unknown values into Off. It now uses the model's SafeModeLevel(wireValue:isReadOnly:) policy. Added regressions for unknown values on read-only connections and renames that preserve unknown wire values.

The AllPlugins build failed because SurrealDB's JSON helper had become a property while its callers still supplied the requested text length. Restored the length-taking helper, keeping display truncation and complete export text.

Verification for these fixes:

  • Full TableProCore package tests: passed, including 1,236 Swift Testing tests plus XCTest.
  • Isolated SwiftPM build of every SurrealDB plugin source with the actual driver test file: 50 tests in 8 suites passed on this branch.
  • AllPlugins Xcode build: passed on feat(plugins): remember row import column mappings per table and add Match by Name and Match by Position #3183 with the corrected helper and PluginKit 34.
  • Project regeneration: passed.
  • SwiftLint on the changed Swift files: zero violations. The helper still flags four existing stale documentation paths (TableProApp/rust-dameng, Contents/MacOS, Contents/Helpers, /Applications/Xcode-beta.app).

Integrated main at 91150eb64 and kept both sets of changelog entries.

Pushing these commits triggers fresh GitHub Actions runs.

Unit-test compile correction

The unit-test build exposed three fixtures still calling the old one-argument cell API: two in Typesense and one in Elasticsearch. They now explicitly pass length: .display, retaining their expected display truncation and write-refusal behavior.

Both fixture files are identical on all four updated branches. The complete test target built on #3183, with all 87 selected storage and write-refusal tests passing. Separately, an isolated SwiftPM build of all Elasticsearch and Typesense driver sources and the actual driver test files passed 175 tests in 14 suites on this branch. SwiftLint found no violations in the two fixture files.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant