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

Can't use $not with $and or $or in embedded document querying

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Another instance of https://jira.mongodb.org/browse/MONGOID-4202

      class Foo
        include Mongoid::Document
        embeds_many :bars
      end
       
      class Bar
        include Mongoid::Document
        embedded_in :foo
       
        field :name, :type => String
      end
       
      f = Foo.new
      f.bars.build(:name => "Building")
      f.save()
      
      # This is what was fixed in MONGOID-4202
      f.bars.where(:name => {:$not => /build/}).count
      => 1
      
      # But these two should definitely == 1
      f.bars.where(:$and => [{:name => {:$not => /build/}}]).count
      => 0
      
      f.bars.where(:$or => [{:name => {:$not => /build/}}]).count
      => 0
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            jonhyman Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: