Skip to content

Mongo 3 + Mongoid 5 Compatibility #2

Open
@simonmorley

Description

@simonmorley

The pull request from DatabaseCleaner/database_cleaner#343 fixes compatibility with Mongo 3 but doesn't address the problem of Mongo 3 + Mongoid 5.

In the current master, the Mongo 2 truncation mixin contains this:

database['system.namespaces'].find(:name => { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
  _, name = collection['name'].split('.', 2)
  name
end

And this commit won't work with mongo v3. Instead, I've found this to work:

session.command(listCollections: 1).first[:cursor][:firstBatch].map do |collection|
    collection[:name]
...

Plus, you also need the sessions function, also excluded:

def session
  ::Mongoid.default_session
end

But that won't work with Mongo 2 I don't believe.

What is the plan for Mongo3 - do you want me to merge this in to a separate module or have you already dealt with?

It seems this has been covered but not for Mongoid 5.

DatabaseCleaner/database_cleaner#343
DatabaseCleaner/database_cleaner#349
andreale/database_cleaner@e9b2c8c
https://github.com/DatabaseCleaner/database_cleaner/issues/386

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions