-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Hey @secnot,
First of all, thanks for creating and opensourcing ISBNField!
I've run into an issue with using unique=True. Apparently ISBNField breaks Django's pre-save uniquess check by doing the checks using the dirty ISBN instead of the cleaned one.
I've created a failing test case here: salomvary@306ab05
Instead of the validation error, it fails with django.db.utils.IntegrityError: UNIQUE constraint failed: tests_uniquecleanisbnmodel.isbn which is not what is expected for these cases.
The problem lies in Django getting the dirty value instead of the clean one here: https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/db/models/base.py#L1097
I am trying to come up with a workaround but as someone who has built zero custom fields so far, I might be slower than you spotting the problem. If you have any insights, let me know!