Tesorio / django-anon

:shipit: Anonymize production data so it can be safely used in not-so-safe environments
https://django-anon.readthedocs.io/en/latest/
MIT License
161 stars 6 forks source link

Create an anon class without defining fields raises `ValueError` #71

Closed felipetio closed 2 years ago

felipetio commented 2 years ago

Checklist

Steps to reproduce

Create an anon class without defining fields, as we can see in the README:


   import anon

   class UserAnonymizer(anon.BaseAnonymizer):
      class Meta:
         model = User

      def clean(self, obj):
         obj.set_password('test')
         obj.save()

Expected behavior

After running the anonymize the password is set to test.

Actual behavior

Using python3.9 and Django2.2 it raises an exception:

  File "/site-packages/anon/base.py", line 89, in run
    bulk_update(
  File "/site-packages/anon/compat.py", line 19, in bulk_update
    manager.bulk_update(objects, fields, **bulk_update_kwargs)
  File "/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/site-packages/django/db/models/query.py", line 491, in bulk_update
    raise ValueError('Field names must be given to bulk_update().')
ValueError: Field names must be given to bulk_update().