Skip to content
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

required: True set on a nullable field which is included in combined_unique #8273

Open
2 of 3 tasks
tiholic opened this issue Dec 4, 2021 · 7 comments
Open
2 of 3 tasks

Comments

@tiholic
Copy link

tiholic commented Dec 4, 2021

Checklist

  • Raised initially as discussion #...
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.

My Model:

class Model:
  f1 = models.CharField()
  f2 = models.CharField()
  f3 = models.CharField(null=True, blank=True)
  
  class Meta:
    unique_together = ('f1', 'f2', 'f3')

This definition implies f1 and f2 should combinedly be unique when f3 is null, but ModelSerializer.get_uniqueness_extra_kwargs marks all fields in unique_together as required: True

Suggestion:

Ignore marking the fields as required: True when there are more than 2 fields in unique_together

Temporary fix

adding default=None on f3 currently bypasses adding required: True on it

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Apr 17, 2022
@stale
Copy link

stale bot commented Jun 19, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Jun 19, 2022
@stale
Copy link

stale bot commented Nov 23, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2022
@merwok
Copy link
Contributor

merwok commented Nov 23, 2022

Closing valid tickets is not solving them

@stale stale bot removed the stale label Nov 23, 2022
@auvipy
Copy link
Member

auvipy commented Nov 24, 2022

that stale bot is annoying but it is also sending me notification for looking into so called stalled issues :D

@auvipy
Copy link
Member

auvipy commented Nov 24, 2022

It is already a deprecated feature in django and DRF still do not support it properly. but if you can send an improvement request it would great

@merwok
Copy link
Contributor

merwok commented Nov 24, 2022

For this ticket, I don’t remember why I found it and subscribed to it.

One project had an issue that was solved by django adding models.UniqueConstraint with condition parameter, so it’s not that.

Maybe this one is stale and won’t fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants