I've found that when one does an upsert using one of the modifiers (increment, set, push, etc.) on a derived document class (i.e. using single collection inheritance), if the document doesn't exist, then the newly created document doesn't have _type set.
I've gotten around this by overriding criteria_hash() in MongoMapper::Plugins::Sci::ClassMethods as follows:
# I override this method so that it works with upserts.
criteria = criteria.merge(:_type => name) if single_collection_inherited?
The above as a gist
Is there any reason this isn't part of the present version? Or would this introduce any problems? If not, it would be nice to see this change added.
Can you provide a unit test for this behavior? I'm not suite sure how to replicate the issue.
Add critera_hash when single collection inherited. Closes #454
Sorry I didn't get back sooner with a spec. I can confirm that this fix solves my problem and the spec you added is equivalent to what I would have offered.