Skip to content

Fix stale children in child formsets - #212

Open
gargikathait wants to merge 1 commit into
wagtail:mainfrom
gargikathait:fix/211-stale-child-formset
Open

gargikathait wants to merge 1 commit into
wagtail:mainfrom
gargikathait:fix/211-stale-child-formset

Conversation

@gargikathait

Copy link
Copy Markdown

Summary

Fixes #211.

When an existing cluster child is re-submitted with a blank ID, BaseChildFormSet.save() previously kept the persisted child and attempted to add the submitted child again. This could result in an IntegrityError when the child model had a uniqueness constraint.

This change removes existing children whose primary keys are not represented by the submitted forms before adding the saved instances.

Testing

  • Added a regression test for re-submitting an existing child with a blank ID.
  • python runtests.py — 171 tests passed.

This branch has not been deployed

No deployments
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.

Child re-submitted with a blank id duplicates an existing cluster child (uncaught IntegrityError)

1 participant