Skip to content

Commit 06f1310

Browse files
committed
fix(R-009): tighten fixupDocumentDbExplain JSDoc, drop dead fallback
Updated JSDoc to document that the input is mutated in place and the return value is the same reference. Removed the unnecessary '| undefined' from the type assertions in ClustersClient since fixupDocumentDbExplain only returns undefined when its input is undefined (which cannot happen in these call sites).
1 parent c61d2af commit 06f1310

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/documentdb/ClustersClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ export class ClustersClient {
11161116
}
11171117
const result = await this._llmEnhancedFeatureApis.explainFind(databaseName, collectionName, verbosity, options);
11181118
const metadata = await this.getClusterMetadata();
1119-
return (fixupDocumentDbExplain(result, metadata) as ExplainResult | undefined) ?? result;
1119+
return (fixupDocumentDbExplain(result, metadata) as ExplainResult) ?? result;
11201120
}
11211121

11221122
/**
@@ -1132,7 +1132,7 @@ export class ClustersClient {
11321132
}
11331133
const result = await this._llmEnhancedFeatureApis.explainAggregate(databaseName, collectionName, pipeline);
11341134
const metadata = await this.getClusterMetadata();
1135-
return (fixupDocumentDbExplain(result, metadata) as ExplainResult | undefined) ?? result;
1135+
return (fixupDocumentDbExplain(result, metadata) as ExplainResult) ?? result;
11361136
}
11371137

11381138
/**

src/documentdb/utils/fixupDocumentDbExplain.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ export function isAzureDocumentDb(metadata: ClusterMetadata | undefined): boolea
2626
}
2727

2828
/**
29-
* Patches the explain result to correct `totalKeysExamined` / `keysExamined` for
30-
* Azure DocumentDB when no index is used.
29+
* Patches the explain result **in place** to correct `totalKeysExamined` / `keysExamined`
30+
* for Azure DocumentDB when no index is used.
3131
*
32-
* @returns The (potentially mutated) explain result, or undefined if input was undefined.
32+
* The input document is mutated directly; the return value is the same reference.
33+
*
34+
* @returns The mutated explain result, or undefined if input was undefined.
3335
*/
3436
export function fixupDocumentDbExplain(
3537
explainResult: Document | undefined,

0 commit comments

Comments
 (0)