IntegrityError even when removing the uniqueness constraint
maxthevoice opened this issue · 1 comments
I previously created a migration to add uniqueness constraint but I had issue when creating instance with empty value when another exists with the same empty value, ei:
{
"en": "foo",
"fr": ""
}
The error looked like:
IntegrityError:
duplicate key value violates unique constraint "controls_questionchoicelist_name_unique_fr"
DETAIL: Key ((name -> 'fr'::text))=() already exists.
Then, I decided to remove the unique constraint, but even if the migration went successfuly, the error was throwing anyway.
-name = LocalizedCharField(blank=False, null=False, required=False, uniqueness=get_language_codes())
+name = LocalizedCharField(blank=False, null=False, required=False)
I had to delete it mannually in my DB. I think this is an issue that could be fixed.
But about my first issue, related to the error, there is a way to prevent empty value to be flag as a duplicate?
I just tried this and it seems to work fine. It correctly drops the constraint. Please make sure you are using the latest version of django-postgres-extra.
Feel free to re-open the issue if you still experience issues.