django-pghistory icon indicating copy to clipboard operation
django-pghistory copied to clipboard

Fix `_generate_history_field()` for `BigAutoField`

Open tobiasmcnulty opened this issue 1 year ago • 0 comments
trafficstars

The way the check for BigAutoField is ordered in _generate_history_field(), it erroneously generates an IntegerField instead of a BigIntegerField in the event/history model. This won't be apparent until the project exceeds the limit for an IntegerField when tracking model changes, and Postgres rejects the value as out of range for an integer.

❯ pip freeze|grep Django              
Django==4.2.13
❯ python manage.py shell         
>>> from django.db.models import AutoField, BigAutoField
>>> isinstance(AutoField(), BigAutoField)
False
>>> isinstance(BigAutoField(), AutoField)
True

tobiasmcnulty avatar Jun 27 '24 22:06 tobiasmcnulty