mongoid/mongoid — Issue #1640: embeds_many on base class causes updates to use $push instead of $set
Author: chriseppstein
Created: 2012-01-24 22:52:02+00:00
State: open

I have created a reproducible test case here: https://github.com/chriseppstein/mongoid_embedded_doc_update_issue

We are currently using the 2.2.x stable branch but I have verified that this issue still exists on master.

What happens is when a base class accesses its collection before the subclass does, the collection gets reused for the whole inheritance tree, then the update tries to find the update consumer for the base class while it was originally set against the subclass.

This issue is affecting us in production and I want to submit a patch asap to address it, but I need you guidance about whether this bug is due to a sharing of the collection object in the base class or because the update consumer is stored against the subclass.