Skip to content

How is restore_on_create supposed to work? #66

@helgihg

Description

@helgihg

I'm not sure if I'm understanding this correctly or if I've discovered some sort of a bug. I'm trying to use restore_on_create to seamlessly restore an object when it has been soft-deleted but is then added again.

The only thing I can find in the documentation is this: "If you need to restore a deleted object instead of re-creating the same one use the restore_on_create attribute:"

My understanding is that if the object which is being created has the same field values as one that already exists in the database but has been soft-deleted, then the soft-deleted object will be restored instead of a new record being created. At the bottom of this post is the relevant data in CSV form. The uppermost comment shows the field names.

It appears to me that the object is indeed identical aside from the removed-field (and the ID, of course). Should I be doing something more than inheriting the model from PermanentModel and including the "class Permanent: restore_on_create = True" thing?

# id, issue_id, log_num, sender_name, committee_id, review_type, date_arrived, date_sent, pdf_remote_path, pdf_filename, sender_name_description, removed

'19004', '7140', '183', 'Alþýðusamband Íslands', '6', 'ub', '2017-02-20', '2017-02-20', 'http://www.althingi.is/altext/erindi/146/146-183.pdf', '', '', '2017-05-21 13:02:13.803763'

'20630', '7140', '183', 'Alþýðusamband Íslands', '6', 'ub', '2017-02-20', '2017-02-20', 'http://www.althingi.is/altext/erindi/146/146-183.pdf', '', '', NULL

So first things first; should this work the way I'm doing it? If so, then I can do some further experiments, although of course it would be helpful if developers have specific questions for me to check out. If I'm doing it wrong, and someone explains to me how it should be done, I can update the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions