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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.1.1
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Minor Change
    • ALL
    • Hide
      (function() {
          "use strict";
       
          db.c.drop();
          db.c.createIndex({a: 1});
          db.c.find({a: {$type: 0}}).itcount();
      }());
      
      Show
      ( function () { "use strict" ; db.c.drop(); db.c.createIndex({a: 1}); db.c.find({a: {$type: 0}}).itcount(); }());
    • Query 2018-06-18
    • 15
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            David Storch
            Reporter:
            David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: