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

$push with only $sort pushes a $sort field

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.3
    • Affects Version/s: 2.4.0-rc0
    • Component/s: Write Ops
    • Labels:
      None

      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
                              }
                      }
              ]
      }
      

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

              Created:
              Updated:
              Resolved: