MongoEngine/mongoengine — pull request #602 by martynsmith (2014-03-11 02:33:14+00:00)
Title: Test to illustrate failure in changed attribute tracking

It seems that commit d868cfdeb08ec2de046f0efac34ae735a4745b6f has introduced a bug.

When you alter a document, then use that document in a reference field of another document before saving it, the changed attributes metadata is reset, meaning when you **do** save, your changes aren't actually saved.

I used git bisect to find the commit indicated above (before that commit this test passes). This means that any version of mongoengine after v0.8.4 has this "bad" behaviour.

I'm not entirely sure how to go about fixing this bug (the code in the above commit looks like it requires some solid understanding of the internals) so I just made a pull request with this test which hopefully someone can use to fix the bug.