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

Better handle transactions in pre-save #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Etenil
Copy link
Contributor

@Etenil Etenil commented May 18, 2020

The pre-save hook makes the assumption that a PK that is set denotes a model update. In transactions it can happen that a PK is defined however the model isn't actually saved yet. The current code causes an error in these conditions.

jsoa added a commit to jsoa/django-easy-audit that referenced this pull request May 18, 2020
@jsoa jsoa mentioned this pull request May 18, 2020
8 tasks
@jheld
Copy link
Collaborator

jheld commented May 19, 2020

Interesting fix. Looks good.

Can you also add a test case?

@Etenil
Copy link
Contributor Author

Etenil commented May 27, 2020

@jheld added test

jheld pushed a commit that referenced this pull request Jul 22, 2020
* [-] CrudEvent object_id as a `CharField`

* [-] Use `pk` instead of `id` in pre_save object lookup

* [-] Fixes issue w/ post_delete / Adds delete test

* [-] Adds updates from #141 PR

* [-] Removes the need for an explicit query

- Uses the internal `_state` object

* [-] Adds `_state` compat test

* [-] Removes sqlite3 test db
@jheld
Copy link
Collaborator

jheld commented Aug 7, 2020

@Etenil can you check if the pre_save logic is still in need of change based on current master?

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

Successfully merging this pull request may close these issues.

2 participants