You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 in UniqueTogetherValidator seems to work as expected. I guess a setting that controls how NULL values are treated could work but it seems a bit out of place.
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?
@auvipy The problem for us is skipping the unique check when any of the values is None regardless of nulls_distinct-value in the unique constraint used.
When nulls_distinct is set to false, nulls in the data are not considered distinct values meaning only one null-value is allowed and duplicates with nulls are possible.
Skipping the check here causes the operation to fail later in the insert due to integrity error.
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: