fix(rustdb-storage): return empty collection list for missing databases

This commit is contained in:
2026-05-28 09:18:48 +00:00
parent 03fabaa26b
commit fd2c3ed63d
6 changed files with 1168 additions and 1940 deletions
+8
View File
@@ -2,6 +2,14 @@
## Pending
### Fixes
- return an empty collection list when `listCollections` is called for a database that does not exist yet
- update release tooling dependencies
- return empty collection list for missing databases (rustdb-storage)
- Return an empty collection list from file and memory storage backends when listing collections for a database that does not exist yet.
- Add a local smartdb regression test for listCollections on a missing database.
- Update release tooling development dependencies.
## 2026-05-20 - 2.10.1
+6 -6
View File
@@ -18,12 +18,12 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsbundle": "^2.10.0",
"@git.zone/tsrun": "^2.0.2",
"@git.zone/tsrust": "^1.3.2",
"@git.zone/tstest": "^3.6.1",
"@types/node": "^25.5.0",
"@git.zone/tsbuild": "^4.4.2",
"@git.zone/tsbundle": "^2.10.4",
"@git.zone/tsrun": "^2.0.4",
"@git.zone/tsrust": "^1.3.4",
"@git.zone/tstest": "^3.6.6",
"@types/node": "^25.9.1",
"mongodb": "^7.1.1"
},
"dependencies": {
+1144 -1929
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -473,7 +473,7 @@ impl FileStorageAdapter {
fn list_collection_dirs(&self, db: &str) -> StorageResult<Vec<String>> {
let db_dir = self.db_dir(db);
if !db_dir.exists() {
return Err(StorageError::NotFound(format!("database '{db}'")));
return Ok(Vec::new());
}
let mut colls = Vec::new();
let entries = std::fs::read_dir(&db_dir)?;
+3 -4
View File
@@ -129,10 +129,9 @@ impl StorageAdapter for MemoryStorageAdapter {
// ---- collection ----
async fn list_collections(&self, db: &str) -> StorageResult<Vec<String>> {
let db_ref = self
.data
.get(db)
.ok_or_else(|| StorageError::NotFound(format!("database '{db}'")))?;
let Some(db_ref) = self.data.get(db) else {
return Ok(Vec::new());
};
Ok(db_ref.iter().map(|e| e.key().clone()).collect())
}
+6
View File
@@ -50,6 +50,12 @@ tap.test('localsmartdb: should connect via returned connectionUri', async () =>
expect(db).toBeTruthy();
});
tap.test('localsmartdb: listCollections should be empty for missing database', async () => {
const missingDb = client.db('missingdb');
const collections = await missingDb.collections();
expect(collections).toEqual([]);
});
tap.test('localsmartdb: should reject double start', async () => {
let threw = false;
try {