Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-763

The query result of embedded document should be consistent.

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.0.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      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?

            Assignee:
            durran Durran Jordan
            Reporter:
            saberma Saber Ma
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: