-
Type:
Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
require 'mongoid'
class Address
include Mongoid::Document
embeds_many :locations
end
class Location
include Mongoid::Document
field :name
embedded_in :address
end
Mongoid.configure.master = Mongo::Connection.new.db('mongoid-bug-2011-03-14')
@address = Address.new(:street => "Clarkenwell Road")
@address.locations << Location.new(:name => 'No.1')
@address.save
#just change the condition order, but the result is difference.
p @address.locations.where(:name.in => ['No.2'], :name.ne => nil ).size #get 0
p @address.locations.where(:name.ne => nil, :name.in => ['No.2']).size #get 1
You can download the code at https://gist.github.com/869147
Run it with mongoid 2.0.0.rc.7
The result is strange.
Any idea?