-
Notifications
You must be signed in to change notification settings - Fork 483
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 truncation on MongoDB 3 #343
Fix truncation on MongoDB 3 #343
Conversation
Fix regexp to skip system collections
Thanks! This really helps a whole lot! |
+1 |
1 similar comment
👍 |
🆗 |
+1 |
collection['name'] | ||
end | ||
.reject do |collection_name| | ||
collection_name =~ /\.system\.|\$/ |
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.
This regexp isn't matching system.<something>
collections. It should be collection_name =~ /.?system\.|\$/
For MongoDB 3.x.x using Wired Tiger storage engine this PR is sufficient, because by default there are no .system.
collections. But if using MongoDB 3.x.x with MMapV1 storage engine, it will fail, because there still is the system.indexes
collection.
Hi @saschaknobloch, thanks for your feedback. I just reused the (already present) regexp that filters out any Could you please clarify better the issue? |
Hey @andreale, here is a link to rubular with the regexp provided with this code, check out yourself: |
BTW: the command http://docs.mongodb.org/manual/reference/command/listCollections/#dbcmd.listCollections This gives us the chance to solve this problem more elegant (but still the regex provided with this PR doesn't work for me ;) ):
|
Relaxed regexp: skips collections like `<database_name>.$cmd`
Thanks @saschaknobloch. I could reproduce the issue on another dev machine (where we also get a
|
+1 |
1 similar comment
+1 |
Since there is no progress on supporting MongoDB 3, we've released our own implementation: https://github.com/td-berlin/mongoid_cleaner We've added It only supports Mongoid and MongoDB 3. It's tested with:
Each against WiredTiger and MMAPv1. Feel free to use and contribute. |
Fix truncation on MongoDB 3
@andreale Thank you! |
As reported on the mongoDB documentation, the collection
system.namespaces
is deprecated and can no longer be used to list the database collections.This PR addresses the deprecation issue by using the command
listCollections
instead. This allow DatabaseCleaner to work with MongoDB 3 with WiredTiger storage engine.