Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13567

Changed behavior of $eq with $sum in aggregation

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0
    • Component/s: Aggregation Framework
    • Labels:
      None
    • ALL

      In releases prior to 2.6 the following statement would work

          "read": { "$sum": { "$eq": [ "$read", true ] } }
      

      Where essentially the "$eq" operation evaluated to true or false and was included in the $sum as either 1 or 0.

      This is always evaluating to 0 when applied to the $sum in 2.6 and now requires wrapping with a $cond operator to produce the desired result:

          "read": { "$sum": { "$cond": [ "$read", 1, 0 ] } }
      

      So I am wondering if this is by design or a bug. It does not seem to be documented as a changed behavior

            Assignee:
            Unassigned Unassigned
            Reporter:
            neillunn Neil Lunn
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: