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

Fix unique together validator doesn't respect condition's fields #9360

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kalekseev
Copy link
Contributor

fixes #9358

else:
queryset = model._default_manager.filter(constraint.condition)
condition_fields = [
f[0].split("__")[0] for f in constraint.condition.children
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how reliable this method of fields extraction

Copy link
Contributor

@sevdog sevdog Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I duobt that this will work when the condition uses a cross-reference between two fields like: Q(first_field__gte=F('second_field')), however I dunno if an unique constraint like that makes sense.

I would like to see also a more complex condition like Q(fielda__isnull=True) | Q(fieldb=False) to be addressed by this validator.

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

Successfully merging this pull request may close these issues.

3.15 regression: Serializer validation failed for unique together constraint
2 participants