Search code examples
mongodbstudio3t

Strange behavior in Studio3T/Mongo


As the Title suggests, I found a rather strange behavior which I am not sure to attribute to Studio3T or to MongoDB.

I have a collection containing simple documents, as follows:

Example of a document in the collection

Whenever I perform a query using the query builder, everything works as expected. However, when I do it using IntelliShell or Aggregate AND if such query is based on the field StudyID, no document is returned, regardless the query.

For example, the two following queries return, respectively, an empty list and no documents.

db.Cortisol.distinct("StudyID")
db.Cortisol.find({},{"StudyID" : 1})

While the following very similar query returns the documents, as expected.

db.Cortisol.find({},{"ExamID" : 1})

As you can see the queries are correct, I did not misspell anything so does anyone have a possible explanation for such a strange behavior?


Solution

  • I wonder if your field "StudyID" contains some weird (invisible) unicode chars. This would explain why dragging the field into query builder works (because the query builder uses the exact same string) and typing S-t-u-d-y-I-D doesn't. When you run an empty query and you see documents with StudyID returned, can you then copy the field name of your StudyID field to the clipboard, and then when you type your query in IntelliShell paste the StudyID name?