fakemongo / fongo

faked out in-memory mongo for java
Apache License 2.0
523 stars 155 forks source link

Projection on a @DBRef field is not working #350

Open SSaev opened 6 years ago

SSaev commented 6 years ago

Hi guys, I have the following documents and collections: collection1:

{
    "_id" : ObjectId("59527c0189672c558385773a"),
    "_class": "collection1",
   "simpleField":"simpleFieldValue"
}

collection2:

{
    "_id" : ObjectId("59527c0189672c558385773c"),
    "collection1Object" : {
        "$ref" : "collection1",
        "$id" : ObjectId("59527c0189672c558385773a")
    }
}

When I do a projection on a real mongo instance like: db.getCollection('collection2').find({_id: ObjectId("59527c0189672c558385773c")}, {"collection1Object.$id" : 1}) I get the correct collection2 object with collection1Object variable being resolved. Unfortunately this is not working in fongo and my collection1Object is being resolved to null