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

listCollections can't filter on collection options when using nameOnly

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • 4.0.0
    • Storage
    • 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 }

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-execution Backlog - Storage Execution Team
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: