[SERVER-4492] $all/$elemMatch needs to be applied to array error for non-existant field Created: 14/Dec/11  Updated: 11/Jul/16  Resolved: 18/Dec/11

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.0.1
Fix Version/s: 2.1.0

Type: Bug Priority: Major - P3
Reporter: David O'Hara Assignee: Aaron Staple
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, Unix


Operating System: ALL
Participants:

 Description   

If I execute an $all/$elemMatch on a collection for a field that is missing from a document in the collection, I get a "$all/$elemMatch needs to be applied to array" error. It can be reproduced in it's simplest form with the following:

> db.example.insert({})
> db.example.find({foo: { $all: [{ $elemMatch: { baz: 'Test'}}]}})
error:

{ "$err" : "$all/$elemMatch needs to be applied to array", "code" : 13021 }

>

The expectation is that no error is thrown and the lack of the field is simply ignored.



 Comments   
Comment by auto [ 18/Dec/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-4492 with all/elemMatch query, fail match rather than assert when document field is not of the expected type
Branch: master
https://github.com/mongodb/mongo/commit/2a31e77375ab2785ace3b396ffedc2fc0053b938

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