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

$push with only $sort pushes a $sort field

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.0-rc0
    • Fix Version/s: 2.5.3
    • Component/s: Write Ops
    • Labels:
      None

      Description

      It seems like this should error out. Example:

      > db.set.update({}, {$push : {a : {$each : [{"title" : "x", "rating" : 6}, {title:"y", "rating" : 3}, {title:"z", rating:10}]}}}, true)
      > db.set.update({}, {"$push" : {"a" : {"$sort" : {"a.rating" : 1}}}})
      > db.set.find().pretty()
      {
              "_id" : ObjectId("512b8e6dae74c67969e404cc"),
              "a" : [
                      {
                              "title" : "x",
                              "rating" : 6
                      },
                      {
                              "title" : "y",
                              "rating" : 3
                      },
                      {
                              "title" : "z",
                              "rating" : 10
                      },
                      {
                              "$sort" : {
                                      "a.rating" : 1
                              }
                      }
              ]
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              scotthernandez Scott Hernandez
              Reporter:
              kristina Kristina Chodorow
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: