{"issue":{"created_at":"2011-12-08T09:47:00Z","state":"open","updated_at":"2011-12-08T10:06:22Z","comments":1,"user":{"gravatar_id":"91fa2dee199f8b076b0e9b6d427f0931","id":3515,"url":"https://api.github.com/users/FND","avatar_url":"https://secure.gravatar.com/avatar/91fa2dee199f8b076b0e9b6d427f0931?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"FND"},"body":"... at least that's what it seems like.\r\n\r\nHere's a reduced test case:\r\nhttps://gist.github.com/1442692\r\nThe last few lines should illustrate the issue. (If not, please let me know so I can elaborate.)\r\n\r\nFWIW, an [earlier, simpler test case](https://gist.github.com/1442692/c3f22792823528f8409b7895ab9088ea874979a6) exhibited the same issue, but @markiz managed to [fix](https://gist.github.com/1442832) (or work around?) that.\r\n\r\nOn IRC @markiz concluded, based on a previous (if old and possibly outdated) [ticket](http://datamapper.lighthouseapp.com/projects/20609/tickets/940-datamapper-010-does-not-recursively-save-parent-resources), that it might be best to manually traverse the object graph and save the respective objects.\r\n\r\nI'm happy to accept that as the recommended solution, but figured it might be worth discussing explicitly.\r\n\r\n\r\nPS: FWIW, this issue was revealed when I [refactored](https://github.com/FND/dm-maker/commit/aeec8c8a70c946779dfc451e95a825181b1d14b4) [dm-maker](https://github.com/FND/dm-maker).","assignee":null,"id":2485480,"number":168,"labels":[],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"recursive saving fails for STI associations","html_url":"https://github.com/datamapper/dm-core/issues/168","closed_at":null,"url":"https://api.github.com/repos/datamapper/dm-core/issues/168","milestone":null},"action":"created","comment":{"created_at":"2011-12-08T10:06:22Z","updated_at":"2011-12-08T10:06:22Z","user":{"gravatar_id":"9b8d8a5d9d726e6875e7d34d1d743eae","id":53611,"url":"https://api.github.com/users/markiz","avatar_url":"https://secure.gravatar.com/avatar/9b8d8a5d9d726e6875e7d34d1d743eae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"markiz"},"body":"I'd like to elaborate.\r\n\r\nThe problem in question seems to be that if you have a graph of objects like this:\r\n\r\n```\r\n     GP\r\n    /  \\\r\n   P1   P2\r\n  / \\    \\\r\n C1  C2   C3\r\n\r\nGP -- grandparent\r\nP  -- parent\r\nC  -- child\r\n```\r\n\r\nAnd you instantiate whole graph and save one of the children, say, C2, then P2 and its children (C3) will not get saved. \r\n\r\nNow you might not know about the parent/child relationship since you can instantiate object both ways (`child = Child.new(:parent => Parent.new)` and `parent = Parent.new(:children => [Child.new])`) so not propagating save to children of parents might lead to some surprise.\r\n\r\nHowever, I have a feeling that this behavior is intended. Some clarification is welcome.","id":3060208,"url":"https://api.github.com/repos/datamapper/dm-core/issues/comments/3060208"}}