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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0.0
    • Component/s: None
    • Labels:
      None

      Description

      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
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: