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

.sum and similar aggregables should ignore sort if not limiting/skipping

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 7.4.0
    • Query
    • None
    • Fully Compatible

    Description

      It appears that when calling a .sum query such as:

        shop.rooms.order(room_number: 1).sum(:capacity)

      In Mongoid 3.0, this would ignore any sort condition

      In Mongoid 7.0 it includes the sort condition in the query

      Since .sum (and related methods) should be completely sort agnostic (the sum is the same no matter how you sort), I think the correct behavior should be to ignore the sort as per Mongoid 3.0. This causes strange behavior when using sorting in default_scope, for example.

       

      Attachments

        Issue Links

          Activity

            People

              oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
              johnny.shields@gmail.com Johnny Shields
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: