myyang / django-pb-model

Protobuf mixin for django model
Other
112 stars 22 forks source link

Create new ProtobufAnyField to allow `Any` to be saved on Django. #28

Closed SilvioMachado closed 4 years ago

SilvioMachado commented 4 years ago

Following issue #26 a new Field was created to allow the developer to be able to have an Any field on Django. This would save him from having to manually convert to bytes somewhere when using Any and being able to work with the model's field directly, E.g. model.any_field being Any instead of bytes, facilitating manipulation.

This is the first implementation of such field, and it was decided to keep it simple, the django method to convert from and to the database are not made to be changed.

Test Coverage:

Name                              Stmts   Miss  Cover   Missing
---------------------------------------------------------------
pb_model/__init__.py                  0      0   100%
pb_model/admin.py                     1      1     0%   1
pb_model/apps.py                      0      0   100%
pb_model/fields.py                  164      9    95%   37, 120, 126, 138-141, 148, 182, 241
pb_model/migrations/__init__.py       0      0   100%
pb_model/models.py                  209      7    97%   260-262, 382, 385-388, 461
pb_model/tests/__init__.py            0      0   100%
pb_model/tests/models.py             42      0   100%
pb_model/tests/models_pb2.py         90      0   100%
pb_model/tests/tests.py             129      0   100%
pb_model/urls.py                      0      0   100%
pb_model/views.py                     0      0   100%
---------------------------------------------------------------
TOTAL                               635     17    97%
myyang commented 4 years ago

Thanks! I'll update PyPi later.