-
Notifications
You must be signed in to change notification settings - Fork 374
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
Reworking "Bugfix/mongodb unsupported char" (pull request #113) #228
Conversation
Quickfix/mongo dot unsupported
…t/node_acl into bugfix/mongodb-unsupported-char
Bugfix/mongodb unsupported char
Pulling from master fork.
Thanks for the patch. I will review it as soon as I can. |
I am wondering, is not that when using invalid collection characters, mongodb will complain? if so, in which case would you like to use raw collection names? |
The problem is with mongodump, a common tool the majority of us use. It cannot create dumps with slashes cause of file system restrictions. Is not a bug, but a really bad practice to allow anything.
Please, refer to pull request #113 and issue #53 for more information.
Raw flag is intended for easy migration and turning feature off if really required.
|
Reminding. If this becomes old, conflicts can happen with newer code changes and it will have to be reworked. |
lib/mongodb-backend.js
Outdated
@@ -199,11 +200,10 @@ MongoDBBackend.prototype = { | |||
} | |||
} | |||
|
|||
function removeUnsupportedChar(text) { | |||
if (typeof text == 'string' || text instanceof String) { | |||
function removeUnsupportedChar(text, useRawColletionNames) { |
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.
I think this method should be part of the prototype, by doing that you will not need to pass useRawCollectionNames in every call.
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.
It will be exposed, is this a problem? Use '_' (internal) prefix?
lib/mongodb-backend.js
Outdated
@@ -12,10 +12,11 @@ var _ = require('lodash'); | |||
// If prefix is specified, it will be prepended to this name, like acl_resources | |||
var aclCollectionName = 'resources'; | |||
|
|||
function MongoDBBackend(db, prefix, useSingle){ | |||
function MongoDBBackend(db, prefix, useSingle, useRawColletionNames){ | |||
this.db = db; |
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.
Note the typo: it is useRawCollectionNames, missing C on the code.
Pulling from fork origin
"useRawColletionNames" -> "useRawCollectionNames"
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.
Typo fixed.
Gonna move the method.
Review changes done. Test needed. I don't have a test environment on my current machine. |
Removes unsupported chars from collection names.
Introduces a flag (
useRawColletionNames
) for easy fallback, since it is a breaking change.Enhances Massot's sanitization by replacing slashes and spaces by underlines, easing reading.
Merges the old pull request code with the latest changes from the master branch of this repository, without conflicts.
Please, review.