8000 When reviving dependent associations, query is not scoped to parent record · Issue #75 · JackDanger/permanent_records · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
When reviving dependent associations, query is not scoped to parent record #75
Open
@masonhale

Description

@masonhale

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).

The 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?

My 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

I 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0