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

Incremental queries on associated objects

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • 10.0.0
    • Affects Version/s: None
    • Component/s: Associations, Query
    • Labels:
      None

      Hi!

      I was trying to do an incremental or query on an associated object, and the resulting query was not what I expected, and I wondered if it was intentional.

      band.
        members.
        or(active: true).
        or(retired: true)
      
      => #<Mongoid::Criteria
        selector: {"$or"=>[{"band_id"=>BSON::ObjectId('652f51ec236b7a3e02183c0c')}, {"active"=>true}, {"retired"=>true}]}
        options:  {}
        class:    Member
        embedded: false>
      

      I was expecting the band_id criteria to be added to each of the array elements. Is there any way to do what I'm looking for? Or would this be considered a bug?

      Thanks!

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: