-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
UniqueTogetherValidator doesn't enforce uniqueness of NULL values on databases that DO enforce them #8409
Comments
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. |
can you please share update with the issue? I am not oracle expert but can this be handled in database model or django level then DRF? also can you share some failing test case for better understanding? |
Django 5.0 supports this in ORM (PostgreSQL 15+ only): https://docs.djangoproject.com/en/5.0/ref/models/constraints/#nulls-distinct |
Checklist
With #2452 code was introduced that changed the behavior of
UniqueTogetherValidator
to ignoreNULL
values.The reasoning being that Postgresql (and supposedly the SQL standard) considers each instance of
NULL
unique from every other instance (last paragraph of https://www.postgresql.org/docs/13/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS). Many RDBMs follow this but Oracle DB doesn't.Oracle DB will enforce multi column unique constraints properly even when some of the values are
NULL
. But DRF will skip the uniqueness check and a constraint violation will be returned by Oracle. Traceback at the end of the ticket.I'm not too sure how such variation between DB backends should be treated. Skipping the
None
check inUniqueTogetherValidator
seems to work as expected. I guess a setting that controls howNULL
values are treated could work but it seems a bit out of place.Thoughts?
Traceback with Oracle DB:
The text was updated successfully, but these errors were encountered: