[SERVER-10278] Assertion: 13111:wrong type for field 3 != 4 - MongoDB C++ driver Created: 21/Jul/13 Updated: 10/Dec/14 Resolved: 29/Jul/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 2.4.0 |
| Fix Version/s: | None |
| Type: | Question | Priority: | Minor - P4 |
| Reporter: | Michael Wayne | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 13.04, MongoDB C++ 2.4 |
||
| Participants: |
| Description |
|
In my MongoDB database I have documents of this form:
Some of them contain the array Event some don't. When I'm trying to process the data using the C++ MongoDB driver 2.4:
I get this error:
In conclusion the condition bo.hasElement("Event") is always true.(???) The program brakes here:
When the array Event has no members. |
| Comments |
| Comment by Michael Wayne [ 23/Jul/13 ] |
|
Thank you! |
| Comment by Scott Hernandez (Inactive) [ 21/Jul/13 ] |
|
This means the field is an embedded document, not an array: http://bsonspec.org/#/specification I suggest you use the shell to inspect your data and see which document has an embedded document, not an array. You could also print the _id to find it more easily. You may want to check the type before calling Array() (that is what Array does internally which resulted in the exception you got). See BSONType (::Array) for the constants/enum to use for checking. Also, it is best to ask these kind of usage questions in the forum (https://groups.google.com/forum/#!forum/mongodb-user) and not to file a jira issue since it is not a bug. |