-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
It would seem that delete_all doesn't map aliased fields in its conditions param correctly. It does the right thing when combined with a separate where call. destroy_all does not seem to have this issue:
class Foo include Mongoid::Document field :_id, :as => :uid, :type => String end Foo.create(:uid => "a") Foo.create(:uid => "b") Foo.create(:uid => "c") Foo.create(:uid => "d") Foo.delete_all(:uid => "a") # => 0 Foo.destroy_all(:uid => "b") # => 1 Foo.where(:uid => "c").delete_all # => 1 Foo.where(:uid => "d").destroy_all # => 1 Foo.all.map(&:uid) # => ["a"]
From the docs I'd expect delete_all and destroy_all to behave in the same way when selecting documents to operate on.
Versions:
mongoid: 4.0.0
moped: 2.0.1
origin: 2.1.1