redis-oplog icon indicating copy to clipboard operation
redis-oplog copied to clipboard

findOne query on server collections with startCaching() returns doc when it shouldn't

Open JackAdams opened this issue 3 years ago • 0 comments

On the Mongo console:

meteor:PRIMARY> db.users.findOne({_id:"ZqRoBNapiGcQTtTBT", nonExistentField: "nonExistentValue"})
null

Which is expected. But in the Meteor shell and in server side app code:

> Meteor.users.findOne({_id:"ZqRoBNapiGcQTtTBT", nonExistentField: "nonExistentValue"})
{
  _id: 'ZqRoBNapiGcQTtTBT',
  ...
}

Which shouldn't be happening. This only happens on collections that have startCaching() on (e.g. Meteor.users.startCaching()) in the server code.

As long as there's an _id that matches, it doesn't matter what other fields there are, the findOne method returns the document. This is not the case for find, which works as expected.

This unexpected behaviour of the findOne method only happens on the server for collections with caching started; it works as expected on the client.

JackAdams avatar Oct 26 '22 23:10 JackAdams