Skip to content

Commit

Permalink
Fix make global serializer() work with extras.
Browse files Browse the repository at this point in the history
  • Loading branch information
iurisilvio committed May 14, 2021
1 parent 5a88587 commit 0c7a2e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion django_qserializer/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def serialize_object(self, obj):
raise NotImplementedError

def serialize(self, objs):
yield from map(self.serialize_object, objs)
yield from map(self._serialize_object, objs)


class _SerializableModelIterable(ModelIterable):
Expand Down
13 changes: 8 additions & 5 deletions django_qserializer/tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ def serialize_object(self, obj):
with django_assert_num_queries(1):
bus = Bus.objects.to_serialize(S(extra=['myattr'])).first()

with django_assert_num_queries(0):
data = bus.serialize()

assert {
expected = {
'plate': 'BUSER',
'myattr': 'Hurricane Cart',
} == data
}

with django_assert_num_queries(0):
assert expected == bus.serialize()

with django_assert_num_queries(0):
assert expected == next(serialize([bus]))
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = django_qserializer
version = 0.2.1
version = 0.2.2
url = https://github.com/buserbrasil/django-qserializer
license = MIT
author = Iuri de Silvio
Expand Down

0 comments on commit 0c7a2e0

Please sign in to comment.