Skip to content

Commit

Permalink
remove gaurd against double explain
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Sep 13, 2024
1 parent 0e44b81 commit 371271d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ export function decorateWithExplain(
maxTimeMS?: number;
} {
type ExplainCommand = ReturnType<typeof decorateWithExplain>;
const isExplainCommand = (doc: Document): doc is ExplainCommand => 'explain' in command;

if (isExplainCommand(command)) {
return command;
}

const { verbosity, maxTimeMS } = explain;
const baseCommand: ExplainCommand = { explain: command, verbosity };

Expand Down
6 changes: 3 additions & 3 deletions test/unit/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,11 @@ describe('driver utils', function () {
});

describe('decorateWithExplain()', function () {
it('when the command is a valid explain command, the command is returned unmodified', function () {
const command = Object.freeze({ explain: { hello: 'world' } });
it('when the command is a valid explain command, the command is still wrapped', function () {
const command = { explain: { hello: 'world' } };
const result = decorateWithExplain(command, Explain.fromOptions({ explain: true }));

expect(result).to.deep.equal(command);
expect(result).to.deep.equal({ explain: command, verbosity: 'allPlansExecution' });
});

it('when the options have a maxTimeMS, it is attached to the explain command', function () {
Expand Down

0 comments on commit 371271d

Please sign in to comment.