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

$unwind of non-array should be allowed

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.0
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Minor Change
    • ALL

      This would effectively just output the existing field.

      > db.reg.find()
      { "_id" : 1, "text" : "foo" }
      { "_id" : 2, "text" : "bar" }
      { "_id" : 3, "text" : "Bar" }
      { "_id" : 4, "text" : [ "bar", "foo" ] }
      >db.reg.aggregate({$match:{text:/ba/i}}, {$unwind:"$text"})
      ...
      	"errmsg" : "exception: $unwind:  value at end of field path must be an array",
      	"code" : 15978,
      	"ok" : 0
      

      This will be important for collections where some document fields may be arrays, but some may not.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            11 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: