fix(rustdb-storage): return empty collection list for missing databases
This commit is contained in:
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
## Pending
|
## 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
|
## 2026-05-20 - 2.10.1
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -18,12 +18,12 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^4.4.0",
|
"@git.zone/tsbuild": "^4.4.2",
|
||||||
"@git.zone/tsbundle": "^2.10.0",
|
"@git.zone/tsbundle": "^2.10.4",
|
||||||
"@git.zone/tsrun": "^2.0.2",
|
"@git.zone/tsrun": "^2.0.4",
|
||||||
"@git.zone/tsrust": "^1.3.2",
|
"@git.zone/tsrust": "^1.3.4",
|
||||||
"@git.zone/tstest": "^3.6.1",
|
"@git.zone/tstest": "^3.6.6",
|
||||||
"@types/node": "^25.5.0",
|
"@types/node": "^25.9.1",
|
||||||
"mongodb": "^7.1.1"
|
"mongodb": "^7.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Generated
+1144
-1929
File diff suppressed because it is too large
Load Diff
@@ -473,7 +473,7 @@ impl FileStorageAdapter {
|
|||||||
fn list_collection_dirs(&self, db: &str) -> StorageResult<Vec<String>> {
|
fn list_collection_dirs(&self, db: &str) -> StorageResult<Vec<String>> {
|
||||||
let db_dir = self.db_dir(db);
|
let db_dir = self.db_dir(db);
|
||||||
if !db_dir.exists() {
|
if !db_dir.exists() {
|
||||||
return Err(StorageError::NotFound(format!("database '{db}'")));
|
return Ok(Vec::new());
|
||||||
}
|
}
|
||||||
let mut colls = Vec::new();
|
let mut colls = Vec::new();
|
||||||
let entries = std::fs::read_dir(&db_dir)?;
|
let entries = std::fs::read_dir(&db_dir)?;
|
||||||
|
|||||||
@@ -129,10 +129,9 @@ impl StorageAdapter for MemoryStorageAdapter {
|
|||||||
// ---- collection ----
|
// ---- collection ----
|
||||||
|
|
||||||
async fn list_collections(&self, db: &str) -> StorageResult<Vec<String>> {
|
async fn list_collections(&self, db: &str) -> StorageResult<Vec<String>> {
|
||||||
let db_ref = self
|
let Some(db_ref) = self.data.get(db) else {
|
||||||
.data
|
return Ok(Vec::new());
|
||||||
.get(db)
|
};
|
||||||
.ok_or_else(|| StorageError::NotFound(format!("database '{db}'")))?;
|
|
||||||
Ok(db_ref.iter().map(|e| e.key().clone()).collect())
|
Ok(db_ref.iter().map(|e| e.key().clone()).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ tap.test('localsmartdb: should connect via returned connectionUri', async () =>
|
|||||||
expect(db).toBeTruthy();
|
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 () => {
|
tap.test('localsmartdb: should reject double start', async () => {
|
||||||
let threw = false;
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user