[SERVER-6852] Disallow empty path components in documents and queries Created: 24/Aug/12  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Aaron Staple Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-5944 modifier failure with empty string fi... Closed
Duplicate
is duplicated by SERVER-3874 Sort and create index don't work for ... Closed
is duplicated by SERVER-12996 Able to insert and upsert documents w... Closed
is duplicated by SERVER-13138 Possible to create documents with emp... Closed
is duplicated by SERVER-9693 Impossible to select a subdocument wi... Closed
is duplicated by SERVER-19740 Reject documents and queries with emp... Closed
Related
related to SERVER-7174 Implement all update() operators Closed
related to SERVER-11812 Can create indexes on invalid fields ... Closed
is related to SERVER-15516 2.6.x secondaries cannot apply update... Closed
is related to SERVER-19725 NULL pointer crash in QueryPlanner::p... Closed
is related to COMPASS-4414 Import via CSV creates fields with em... Closed
is related to SERVER-6999 Embedded "dot-notation" fields broken... Closed
is related to SERVER-2051 Disallow empty string keys Open
Assigned Teams:
Query Execution
Participants:
Case:

 Description   

Empty string field names are allowed in json, and they are currently allowed in mongo documents. However there are many places in mongo code where empty string field names are not supported correctly, often because the empty string is used as an internal sentinel value in the implementation of various features.

In addition to the linked cases, here are some others:

Projection of an empty string field has opposite of desired effect:

> c = db.c;
test.c
> c.drop();
true
> c.save( { '':'foo' } );
> c.find( {}, { '':0 } );
{ "_id" : ObjectId("5037e1fd4764d2aca5d2cc35"), "" : "foo" }
> c.find( {}, { '':1 } );
{ "_id" : ObjectId("5037e1fd4764d2aca5d2cc35") }

FieldPath doesn't allow empty string field names (SERVER-6592), I think there are a number of cases where the aggregation framework won't handle them.

Once we decide what to do about empty string fields we should do an audit to ensure we correctly implement the desired behavior.



 Comments   
Comment by J Rassi [ 18/Mar/14 ]

Note that as of 2.5.5, ensureIndex({"":1}) will return an error (SERVER-11812).

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