ephios
ephios copied to clipboard
unique_together constraint violated with QualificationGrant formset in UserProfileForm
After introducing a unique_together constraint for users and qualifications on QualificationGrant in #210 there is the following bug:
Assuming a user has the qualification A and you load the form for this user, you can remove qualification A. Before saving, add a new qualification and select A. If you save the form now, it will have an error because the unique_together constraint is violated because the user already has the qualification A.
This could be solved by deferrable constraints, but they are only supported on postgres. We could also write our own validation logic instead of using the database constraint