Skip to content

Add tests for unique validation for bulk creation in model serializers #6396

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

Closed
wants to merge 2 commits into from

Conversation

maribedran
Copy link

@maribedran maribedran commented Jan 7, 2019

Description

The unique validation in model serializers only checks for existing entries on the database. If the serializer is instanced with many=True and receives more than one item in the data argument having the same value for a unique field, the .is_valid() method returns True, but calling .save() will raise an IntegrityError.

Related to issue #6395

The unique validation in model serializers only check for existing
entries on the database. If the serializer is instanced with many=True
and receives more than one item in the data argument having the same
value for a unique field, the .is_valid() method returns True, but
calling .save() will raise an IntegrityError.
Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

can you rebase this? also, do ou have any fix in mind?

@maribedran
Copy link
Author

Will do. Thanks!

I looked into the model serializer classes, but couldn't decide on a good path to put the logic of calling this validation. Especially on how to add errors to the list serializer. I'd love to hear any suggestions.

For now I thought of adding a note to the docs with the example I described on the related issue #6395.

@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 the stale label Jun 19, 2022
@auvipy auvipy closed this Dec 15, 2022
@auvipy auvipy reopened this Dec 15, 2022
@stale stale bot removed the stale label Dec 15, 2022
@auvipy auvipy added the Bug label Dec 15, 2022
@stale
Copy link

stale bot commented Feb 18, 2023

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 Feb 18, 2023
@auvipy auvipy removed the stale label May 17, 2023
@stale
Copy link

stale bot commented Aug 13, 2023

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 Aug 13, 2023
Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

it would be great if you can re visit it

@stale stale bot removed the stale label Aug 15, 2023
@stale
Copy link

stale bot commented Oct 15, 2023

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 Oct 15, 2023
@auvipy auvipy closed this Nov 10, 2023
@auvipy auvipy reopened this Nov 10, 2023
@stale stale bot removed the stale label Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants