Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is restore_on_create supposed to work? #66

Open
helgihg opened this issue May 21, 2017 · 1 comment
Open

How is restore_on_create supposed to work? #66

helgihg opened this issue May 21, 2017 · 1 comment

Comments

@helgihg
Copy link

helgihg commented May 21, 2017

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.

@helgihg
Copy link
Author

helgihg commented May 21, 2017

I have figured this out by reading the code, and contributed a pull request to update the README so that it's clearer how this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant