Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-5102): fix listDatabases nameOnly setting is sent as NaN #3742

Merged
merged 8 commits into from Jul 3, 2023

Conversation

redixhumayun
Copy link
Contributor

@redixhumayun redixhumayun commented Jun 23, 2023

Description

Fixes the issue described in NODE-5102 where nameOnly was being coerced into NaN using the Number constructor.

What is changing?

Now, the nameOnly property is coerced to a boolean following the example laid out by listCollections. Accompanying unit tests have also been added.

Is there new documentation needed for these changes?

No

What is the motivation for this change?

Fixes NODE-5102

Release Highlight

listDatabases nameOnly option bug fix

The listDatabases API exposes the nameOnly option which allows you to limit its output to only the names of the databases on a given mongoDB deployment:

db.admin().listDatabases({ nameOnly: true });
// [
//   { name: 'local' },
//   { name: 'movies' },
//   ...
// ]

Prior to this fix, the option was not being set properly on the command, so the output was always given in full.

Thanks to @redixhumayun for submitting this fix!

See #3742 for details.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

…oolean. Also assigning that directly to the cmd object in execute. Added tests for listDatabases
@dariakp dariakp added tracked-in-jira Ticket filed in MongoDB's Jira system External Submission PR submitted from outside the team labels Jun 23, 2023
@W-A-James W-A-James self-assigned this Jun 26, 2023
@W-A-James W-A-James added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jun 26, 2023
Copy link
Contributor

@W-A-James W-A-James left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @redixhumayun, thanks so much for this PR. I have left some specific comments on the files below. In addition to the unit tests you have written, before we can approve this change, we would need to have integration tests that would test this behaviour against a mongod instance. It would be good to create a new file for these in test/integration/enumerate_databases.test.ts.

Please see the running tests locally section section of our test readme for details on how to get integration tests running locally.

For an example of how to write an integration test in this repo, please see the findAndModify tests.

src/operations/list_databases.ts Outdated Show resolved Hide resolved
src/operations/command.ts Outdated Show resolved Hide resolved
test/unit/operations/list_databases.test.js Outdated Show resolved Hide resolved
@W-A-James
Copy link
Contributor

@redixhumayun We do want to merge this change fairly soon, so we will take over the remaining code changes on this PR. Thanks again for your submission!

test/integration/enumerate_databases.test.ts Outdated Show resolved Hide resolved
test/unit/operations/list_databases.test.ts Outdated Show resolved Hide resolved
test/integration/enumerate_databases.test.ts Outdated Show resolved Hide resolved
test/integration/enumerate_databases.test.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Jun 29, 2023
@W-A-James W-A-James requested a review from nbbeeken June 30, 2023 13:28
@nbbeeken nbbeeken merged commit b97132e into mongodb:main Jul 3, 2023
17 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Submission PR submitted from outside the team Team Review Needs review from team tracked-in-jira Ticket filed in MongoDB's Jira system
Projects
None yet
5 participants