-
-
Notifications
You must be signed in to change notification settings - Fork 7k
fix(blank/unique): add default
handling for blank=True
field
#9751
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
base: master
Are you sure you want to change the base?
fix(blank/unique): add default
handling for blank=True
field
#9751
Conversation
Signed-off-by: Sergei Shishov <sshishov.sshishov@gmail.com>
3bcd191
to
8de6a6c
Compare
I have added tests similar to the tests added in #9531 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you check this pr #9725 ?
class Meta: | ||
constraints = [ | ||
# Unique constraint on 2 blank fields | ||
models.UniqueConstraint(name='unique_constraint', fields=('age', 'tag'), condition=~models.Q(models.Q(title='') & models.Q(tag='True'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have a char length limit here?
@@ -714,6 +774,12 @@ def test_single_field_uniq_validators(self): | |||
ids_in_qs = {frozenset(v.queryset.values_list(flat=True)) for v in validators if hasattr(v, "queryset")} | |||
assert ids_in_qs == {frozenset([1]), frozenset([3])} | |||
|
|||
def test_blank_uqnique_constraint_fields_are_not_required(self): | |||
serializer = UniqueConstraintBlankSerializer(data={'age': 25}) | |||
self.assertTrue(serializer.is_valid(), serializer.errors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split it into multiple assertions?
@@ -714,6 +774,12 @@ def test_single_field_uniq_validators(self): | |||
ids_in_qs = {frozenset(v.queryset.values_list(flat=True)) for v in validators if hasattr(v, "queryset")} | |||
assert ids_in_qs == {frozenset([1]), frozenset([3])} | |||
|
|||
def test_blank_uqnique_constraint_fields_are_not_required(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here
Description
This MR should fix the issue with
blank=True
field inUniqueTogether
constraint. It should not become required all of a sudden.Fixes #9750