-
Notifications
You must be signed in to change notification settings - Fork 235
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
feat: Fix for issue#663 #666
base: master
Are you sure you want to change the base?
Conversation
Hi @achrinza , on my local setup when I got a Mongo docker image and then ran |
I suspect it's because of these lines: loopback-connector-mongodb/setup.sh Line 44 in 5936ba0
loopback-connector-mongodb/setup.sh Line 49 in 5936ba0
The CI pipeline pins to v4.4:
Compare to Try changing the line in your local copy of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR, @jaishirole, most of it looks great! Just have a few comments 👇
lib/mongodb.js
Outdated
self.settings.url = urlObj.toString(); | ||
// This is special processing if database is not part of url, but is in settings | ||
if (self.settings.database && self.settings.url) { | ||
if ((self.settings.url.indexOf('/' + self.settings.database) === -1) && (self.settings.url.indexOf('authSource=' + self.settings.database) === -1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this condition supposed to be OR, or is authSource
identical to the /database-name
syntax?
if ((self.settings.url.indexOf('/' + self.settings.database) === -1) && (self.settings.url.indexOf('authSource=' + self.settings.database) === -1)) { | |
if ((self.settings.url.indexOf('/' + self.settings.database) === -1) || (self.settings.url.indexOf('authSource=' + self.settings.database) === -1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achrinza My thinking is, if someone is including authSource, they do know of their database. If I change this to an 'OR', I see that for every mongoURL, the new logic will be invoked. I was trying to see how to narrow down calls into it and hence '&&' made sense as this lets us process the URL if url doesn't have a database specified (after /
) and not even in authSource
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achrinza This indeed is a flaky condition, let me think over and push a fix. The unit tests directly call the new function, hence I missed testing this part. Will take care of it in new commit. Can you trigger the workflow, to see other issues are taken care now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achrinza Pushing a new commit with modified condition as well as adding a few more functional test cases that will execute the new function more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achrinza Thanks much for the review comments. I'll incorporate the changes later today. |
In the new commit, added handling so that even for latest Mongo, it should work. :) |
Pull Request Test Coverage Report for Build 2190805686Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Not sure why the coverage plummeted to zero, but the test runs themselves look ok. |
@achrinza Sorry, didn't get time during the day. Will look into tomorrow. I have an idea of what is missing. |
@achrinza Can you help trigger the Workflow to see what happens this time ? |
Workflow triggered - Just a heads up, our workflow doesn't allow merging PRs with Merge Commits, so they'll need to be dropped and, if needed, replaced with a rebase instead. |
Oh, didn't know. Looking into how to remove the merge commit from this PR now.. Any tips ? |
Hi @achrinza , the merge commit is now dropped. Please review and let me know if I should fix anything more. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in review. The changes LGTM 👍
Just need to squash into a single Git Commit.
A suggested Git Commit message would be:
fix: connection string seed list parsing
closes: https://github.com/loopbackio/loopback-connector-mongodb/issues/663
Thanks for applying the changes and sorry for the delayed review; Everything LGTM 👍 Just need to squash into a single Git Commit and it can be merged. |
closes: loopbackio#663 Signed-off-by: jaishirole <[email protected]>
@achrinza I was on vacation and the squashing took unnecessarily longer. I'm sorry for the delay. Can you please help with the next steps here? Thanks much for all your guidance so far! |
Hi all, is there any update on this? Thanks |
@dhmlau Hi all, is there any update on this? Thanks |
@manarhusrieh, this PR was approved by @achrinza, so I'd assume it's good to go. Question for @achrinza, this PR is for the |
@dhmlau This should be merged into v7 now. v6 was the latest major version at that time. |
@achrinza can't this be merged to version 6? This is an issue with the package, not a new feature. We are currently using this PR package instead of the official one and it is working properly for more than a year. |
@manarhusrieh, could you please submit a new PR against the |
@dhmlau OK, I'll prepare a PR against version 6. Thanks |
Signed-off-by: jaishirole [email protected]
Description of changes
Fixes #663
Makes sure that fix does cover #610 too
Since Mongo Connection URLs can have commas in it, the URL class based on WHATWG standard in current state, is unable to parse these URLs. Though there exists a method to construct a MongoDB URL from the settings, the code change was needed to parse a MongoURL and explicitly insert database if one exists in the settings. This will happen only if
the url doesn't have a database specified and settings has it.
Please note that I have modified expected results of 3 existing unit test cases as the current Mongo version now returns a different error message than in the past.
The package-lock.json is added based on modifications seen on my system.
This is my first commit in Loopback project, looking forward to the feedback if something isn't done right way. Thanks!
Checklist
npm test
passes on your machine