Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-11803

Docs for SERVER-35454: Query system does not fail cleanly for $type:0 when an index is available

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.1.1
    • manual, Server
    • None

    Description

      Description:

      The ability to use {$type: 0} was a misfeature that was never correctly implemented. Since 0 is the "EOO" type code, this query could have been used to find documents in which a particular field is missing. However, the correct and fully supported way to do this is {$exists:false}. The {$type:0} predicate never worked if the field was indexed. Furthermore, we have never permitted something like {$type: "missing"}.

      There is a possibility that a small body of users had written queries that depended on this misfeature. 4.2 completely removes support for it. We should probably document that {$type:0} and {$type:"missing"} are not supported, and that {$exists:false} should be used instead.

      Scope of changes:

      We don't mention type 0. So, changes will be minimal where related to using type/exists for field existence check.

      • 4.2-compat
      • footnote in $type and $exists
      • note in /tutorial/query-for-null-fields

      Impact to other docs outside of this product:

      none

      MVP:

      Resources:

      Engineering Ticket Description:

      The $type query predicate should not support type code 0, as this is used internally for the "missing" or "EOO" BSON type. The system should reject an attempt to use $type:0 with a clear error message. Instead, when an index is available for use by the $type predicate, the server returns an internal error message such as the following:

      {
      	"ok" : 0,
      	"errmsg" : "type not supported for appendMinElementForType",
      	"code" : 10061,
      	"codeName" : "Location10061"
      }
      

      Users who wish to check for existence of a field should instead use $exists:false.

      Attachments

        Issue Links

          Activity

            People

              kay.kim@mongodb.com Kay Kim (Inactive)
              kay.kim@mongodb.com Kay Kim (Inactive)
              Jess Mokrzecki Jess Mokrzecki
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                4 years, 42 weeks, 3 days ago