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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.4.0
    • Affects Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Fully Compatible

      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.

       

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

              Created:
              Updated:
              Resolved: