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

Investigate why listCollections validates views that should not be returned when the filter is an $and

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Query Execution

    Description

      According to the comment in list_collections_no_view.js which got added in SERVER-25942, when listCollections doesn't need to return a view, it should validate it. But it looks like it if we change the filter from this

      {
                     "$or": [
                           {    
                                 "type": "collection"
                            }, 
                            {
                                  "type": {
                                          $exists: false
                                    }
                             }
                      ]
      }
      

      to this,

      {
      		"$and" : [
      			{
      				"name" : {
      					"$ne" : "system.profile"
      				}
      			},
      			{
      				"$or" : [
      					{
      						"type" : "collection"
      					},
      					{
      						"type" : {
      							"$exists" : false
      						}
      					}
      				]
      			}
      		]
      	}
      }
      

      the listCollection command would fail with the error below:

      {
      	"ok" : 0,
      	"errmsg" : "Invalid view definition detected in the view catalog. Remove the invalid view manually to prevent disallowing any further usage of the view catalog.",
      	"code" : 182,
      	"codeName" : "InvalidViewDefinition"
      }
      

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: