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

Serializers with many=True should return empty list rather than empty dict #3434

Closed
nip3o opened this issue Sep 23, 2015 · 4 comments
Closed
Labels

Comments

@nip3o
Copy link

nip3o commented Sep 23, 2015

A serializer with many=True returns a list of dicts when accessing serializer.errors or serializer.validated_data. If these are empty, however, an empty dict is returned (just as when many=False). I believe that it would be more consistent to return an empty list in this case.

Example test case: https://github.com/tomchristie/django-rest-framework/compare/tomchristie:master...nip3o:empty-errors?expand=1

==================================================================================== FAILURES ====================================================================================
_______________________________________________________________ BulkCreateSerializerTests.test_bulk_create_errors ________________________________________________________________
tests/test_serializer_bulk_update.py:80: in test_bulk_create_errors
    self.assertEqual(serializer.validated_data, [])
E   AssertionError: {} != []
_______________________________________________________________ BulkCreateSerializerTests.test_bulk_create_success _______________________________________________________________
tests/test_serializer_bulk_update.py:49: in test_bulk_create_success
    self.assertEqual(serializer.errors, [])
E   AssertionError: {} != []
================================================================ 2 failed, 743 passed, 2 warnings in 7.98 seconds ===============================================================
@tomchristie
Copy link
Member

Any chance you could submit those as a pull request? That'd help move things along further than linking to a diff.

@nip3o
Copy link
Author

nip3o commented Sep 23, 2015

Done!

@tomchristie
Copy link
Member

👍

@awwester
Copy link
Contributor

@jpadilla should this be closed or is there something remaining?

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

No branches or pull requests

3 participants