[DOCS-11803] Docs for SERVER-35454: Query system does not fail cleanly for $type:0 when an index is available Created: 17/Jun/18  Updated: 13/Nov/23  Resolved: 04/Dec/18

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.1.1, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Kay Kim (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-35454 Query system does not fail cleanly fo... Closed
Participants:
Days since reply: 5 years, 10 weeks, 1 day ago
Epic Link: DOCS: 4.2 Server/Tools

 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.



 Comments   
Comment by Githook User [ 04/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-11803: 4.2 - $type: 0
Branch: master
https://github.com/mongodb/docs/commit/fcc080585e38adc4ab82dad48f37507058d07ac6

Generated at Thu Feb 08 08:03:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.