{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1113","labels_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1113/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1113/comments","events_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1113/events","html_url":"https://github.com/doctrine/mongodb-odm/pull/1113","id":84158978,"number":1113,"title":"Functional test to exhibit bug: strategy=\"atomicSet\" does not atomically update a database record","user":{"login":"blockjon","id":1198745,"avatar_url":"https://avatars.githubusercontent.com/u/1198745?v=3","gravatar_id":"","url":"https://api.github.com/users/blockjon","html_url":"https://github.com/blockjon","followers_url":"https://api.github.com/users/blockjon/followers","following_url":"https://api.github.com/users/blockjon/following{/other_user}","gists_url":"https://api.github.com/users/blockjon/gists{/gist_id}","starred_url":"https://api.github.com/users/blockjon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blockjon/subscriptions","organizations_url":"https://api.github.com/users/blockjon/orgs","repos_url":"https://api.github.com/users/blockjon/repos","events_url":"https://api.github.com/users/blockjon/events{/privacy}","received_events_url":"https://api.github.com/users/blockjon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-02T19:03:34Z","updated_at":"2015-06-02T21:34:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1113","html_url":"https://github.com/doctrine/mongodb-odm/pull/1113","diff_url":"https://github.com/doctrine/mongodb-odm/pull/1113.diff","patch_url":"https://github.com/doctrine/mongodb-odm/pull/1113.patch"},"body":"Beta13 introduced @malarzm 's https://github.com/doctrine/mongodb-odm/pull/1096 which helps make Doctrine ODM atomically insert and update records.\r\n\r\nI was just checking my application and in which I have been experiencing data loss & corruption but I see the problem is still not fixed, even with atomicSet enabled using beta13.\r\n\r\nI believe the problem may be that the solution introduced in https://github.com/doctrine/mongodb-odm/pull/1096 does not correctly handle embedMany's that are nested inside each other when changes are made to the embedded collection which is 2 levels down.\r\n\r\nIn this PR, I demonstrate this problem by creating a Book object which has 1 Chapter .. and where the chapter has 1 Page.  (book->chapters->pages) When I save the object using strategy=\"atomicSet\", everything is saved in a single atomic operation - this is very very good.\r\n\r\nHowever, when I load the object from the database and try to add a new Page to the chapter, Doctrine executes two separate queries. For me, this means continued data loss & corruption.\r\n\r\nHere's how to reproduce the failing test:\r\n```\r\nphpunit --filter testAtomicSetWorksAsExpected\r\n```\r\noutput:\r\n```\r\nPHPUnit 4.1.6 by Sebastian Bergmann.\r\n\r\nConfiguration read from /mongodb-odm/phpunit.xml\r\n\r\nF\r\n\r\nTime: 1.44 seconds, Memory: 21.25Mb\r\n\r\nThere was 1 failure:\r\n\r\n1) Doctrine\\ODM\\MongoDB\\Tests\\Functional\\VersionTest::testAtomicSetWorksAsExpected\r\nDespite use of atomicSet, 2 queries were detected when flushing this change. We expected only one query.\r\nFailed asserting that 2 matches expected 1.\r\n\r\n/mongodb-odm/tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php:77\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 2, Failures: 1.\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/comments/108104689","html_url":"https://github.com/doctrine/mongodb-odm/pull/1113#issuecomment-108104689","issue_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1113","id":108104689,"user":{"login":"malarzm","id":4947711,"avatar_url":"https://avatars.githubusercontent.com/u/4947711?v=3","gravatar_id":"","url":"https://api.github.com/users/malarzm","html_url":"https://github.com/malarzm","followers_url":"https://api.github.com/users/malarzm/followers","following_url":"https://api.github.com/users/malarzm/following{/other_user}","gists_url":"https://api.github.com/users/malarzm/gists{/gist_id}","starred_url":"https://api.github.com/users/malarzm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malarzm/subscriptions","organizations_url":"https://api.github.com/users/malarzm/orgs","repos_url":"https://api.github.com/users/malarzm/repos","events_url":"https://api.github.com/users/malarzm/events{/privacy}","received_events_url":"https://api.github.com/users/malarzm/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T21:34:44Z","updated_at":"2015-06-02T21:34:44Z","body":"Ok, I have found what goes wrong but I'm still wondering what versioning has to do with that"}}