destroy_all can't be called on a query object; fails silently/horrifically #458

dreeves opened this Issue Sep 30, 2012 · 4 comments


None yet

3 participants


Here's how this went down for us. Write a little query to find the objects you want:


Inspect your results. Confirm that is totally the set of objects you want to blow to smithereens. Yes, yes it is. I feel totally confident (well, maybe slightly anxious, let's be honest now) in blowing away that results set.



Result: ALL the datapoint objects are destroyed!

Googling around suggests that a similar thing has been seen with Mongoid but I'm not seeing anything for Mongomapper. Eager to hear others' opinions on this issue, if you agree it's a bug, etc. Thanks!


I cannot reproduce this using MongoMapper 0.12.0 and a simple model that looks like

class Datapoints
  include MongoMapper::Document

I get

NoMethodError: undefined method `destroy_all' for #<Plucky::Query:0x007fa7d34c3b50>

This makes sense since Datapoints.where returns a Plucky::Query instance, which doesn't have a destroy_all method. Am I missing something here?


It does return that error but it has the side effect of first actually deleting everything in the collection! Sorry I didn't clarify that. We went into more detail here:


Whoa! You're right. That's really bad.


Fixed in master.

@jnunemaker jnunemaker closed this Dec 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment