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

listCollections can't filter on collection options when using nameOnly

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.0.0
    • Component/s: Storage
    • Labels:
    • Storage Execution
    • ALL
    • Hide
      MongoDB Enterprise > db.createCollection("cappitycapcap", {capped:true, size:100})
      { "ok" : 1 }
      MongoDB Enterprise > db.runCommand({listCollections:1, filter:{"options.capped":true}, nameOnly: true})
      {
              "cursor" : {
                      "id" : NumberLong(0),
                      "ns" : "lcbug.$cmd.listCollections",
                      "firstBatch" : [ ]
              },
              "ok" : 1
      }
      MongoDB Enterprise > db.runCommand({listCollections:1, filter:{"options.capped":true}})
      {
              "cursor" : {
                      "id" : NumberLong(0),
                      "ns" : "lcbug.$cmd.listCollections",
                      "firstBatch" : [
                              {
                                      "name" : "cappitycapcap",
                                      "type" : "collection",
                                      "options" : {
                                              "capped" : true,
                                              "size" : 256
                                      },
                                      "info" : {
                                              "readOnly" : false,
                                              "uuid" : UUID("abf81435-62d6-4247-85c6-6bc4bc9bfff2")
                                      },
                                      "idIndex" : {
                                              "v" : 2,
                                              "key" : {
                                                      "_id" : 1
                                              },
                                              "name" : "_id_",
                                              "ns" : "lcbug.cappitycapcap"
                                      }
                              }
                      ]
              },
              "ok" : 1
      }
      
      Show
      MongoDB Enterprise > db.createCollection("cappitycapcap", {capped:true, size:100}) { "ok" : 1 } MongoDB Enterprise > db.runCommand({listCollections:1, filter:{"options.capped":true}, nameOnly: true}) { "cursor" : { "id" : NumberLong(0), "ns" : "lcbug.$cmd.listCollections", "firstBatch" : [ ] }, "ok" : 1 } MongoDB Enterprise > db.runCommand({listCollections:1, filter:{"options.capped":true}}) { "cursor" : { "id" : NumberLong(0), "ns" : "lcbug.$cmd.listCollections", "firstBatch" : [ { "name" : "cappitycapcap", "type" : "collection", "options" : { "capped" : true, "size" : 256 }, "info" : { "readOnly" : false, "uuid" : UUID("abf81435-62d6-4247-85c6-6bc4bc9bfff2") }, "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "lcbug.cappitycapcap" } } ] }, "ok" : 1 }

      When using listCollections with the nameOnly option and a filter, it looks like the filter is applied after retrieving only name information.

      The documentation isn't clear that this is what should occur and the behavior could be surprising to users.

      Another possible improvement would be to have the command fail if nameOnly is true and the filter contains any keys other than name.

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: