Created
March 14, 2011 13:58
-
-
Save saberma/869147 to your computer and use it in GitHub Desktop.
The query result of embedded document is inconsistent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ).first | |
p @address.locations.where(:name.ne => nil, :name.in => ['No.2']).first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment