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

Scopes on embedded docs sometimes attempt to query non-embedded collection, incorrectly returning empty/0 results

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 5.1.0
    • Affects Version/s: 5.0.1, 5.1.0
    • Component/s: None
    • Labels:
      None

      When building queries for embedded documents, if one scope calls another that uses an order_by(), then the query acts as if the embedded document is not embedded and queries for the non-existant collection.

      See attached example code. Log entries showing the incorrect queries against "insides" are also generated.

      Including the order_by() in the parent scope works correctly.

      Tested and confirmed as broken in 5.0.1, 5.0.0-stable, and master. Worked in Mongoid 4.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            tmorgan thomas morgan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: