{"action":"opened","issue":{"url":"https://api.github.com/repos/JackDanger/permanent_records/issues/75","repository_url":"https://api.github.com/repos/JackDanger/permanent_records","labels_url":"https://api.github.com/repos/JackDanger/permanent_records/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/JackDanger/permanent_records/issues/75/comments","events_url":"https://api.github.com/repos/JackDanger/permanent_records/issues/75/events","html_url":"https://github.com/JackDanger/permanent_records/issues/75","id":158730878,"number":75,"title":"When reviving dependent associations, query is not scoped to parent record","user":{"login":"masonhale","id":69448,"avatar_url":"https://avatars.githubusercontent.com/u/69448?v=3","gravatar_id":"","url":"https://api.github.com/users/masonhale","html_url":"https://github.com/masonhale","followers_url":"https://api.github.com/users/masonhale/followers","following_url":"https://api.github.com/users/masonhale/following{/other_user}","gists_url":"https://api.github.com/users/masonhale/gists{/gist_id}","starred_url":"https://api.github.com/users/masonhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masonhale/subscriptions","organizations_url":"https://api.github.com/users/masonhale/orgs","repos_url":"https://api.github.com/users/masonhale/repos","events_url":"https://api.github.com/users/masonhale/events{/privacy}","received_events_url":"https://api.github.com/users/masonhale/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-06T17:27:11Z","updated_at":"2016-06-06T17:27:11Z","closed_at":null,"body":"I was just debugging an issue when trying to revive a deleted record, and I found that that when reviving the dependent associations for the record, the query is not scoped to the parent record. By that I mean the query does not include the foreign key. Rather it merely looks for *any* record of the given type that happened to be deleted within the timeframe of the deleted_at (plus/minus the depended_record_window).\r\n\r\nThe result is that completely unrelated records could be revived if they happened to be deleted around the same time (something quite likely on a high traffic app). Surely this isn't the way it is meant to work is it?\r\n\r\nMy expectation is that query generated by `add_record_window` method would include the foreign_key of the containing record. See: https://github.com/JackDanger/permanent_records/blob/master/lib/permanent_records.rb#L134-L144\r\n\r\nI can try to create a patch for this issue, but first I would like to know if this is working 'as designed' if there is not reason the foreign key is not included?\r\n"}}
{"actor":{"display_login":"masonhale"}}