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: Remove instanceof comparison for MongoDB DB instance check #112

Merged
merged 1 commit into from
Apr 16, 2020

Conversation

stieg
Copy link
Contributor

@stieg stieg commented Feb 12, 2020

We can not reasonably use an instanceof comparison to confirm that a
given object is of type MongoDB since we may be using a different
version of MongoDB than what a caller might be using. In this
scenario the check would fail. Thus this patch checks if a required
field in the IDbProperties object is set. This required field is not a
known field in MongoDB instance, thus it is arguably sane to check it
in this manner.

We can not reasonably use an `instanceof` comparison to confirm that a
given object is of type MongoDB since we may be using a different
version of MongoDB than what a caller might be using.  In this
scenario the check would fail. Thus this patch checks if a required
field in the IDbProperties object is set. This required field is not a
known field in MongoDB instance, thus it is arguably sane to check it
in this manner.
@stieg stieg force-pushed the r/stieg/instanceof-fix branch from 171b358 to 20cc7d0 Compare February 12, 2020 22:47
} else {
const options = { ...this.options.db.options };

// Check if connectionUrl exists. If it does, assume its IDbProperties object
Copy link
Owner

@emmanuelbuah emmanuelbuah Feb 12, 2020

Choose a reason for hiding this comment

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

Per discussion with @stieg, one solution is to make MongoDB a devDependency making it so the logic uses the consumer's own MongoDB package.

Copy link
Owner

@emmanuelbuah emmanuelbuah left a comment

Choose a reason for hiding this comment

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

Per comment in PR, we will address the instanceof issue correctly in a future release. Will merge this
now to address current breaking changes.

@jamesholcomb
Copy link
Contributor

Is a new release coming soon? I am working around it by specifying connectionUrl but that has a issue #113 attached as well.

@emmanuelbuah
Copy link
Owner

Merging this for now. Will put in place a better solution (traced by #148) to address the instanceof issue in the future.

@emmanuelbuah emmanuelbuah merged commit 05ef439 into emmanuelbuah:master Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants