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

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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.1
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      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

      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@mongodb.com David Storch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: