django-pghistory
django-pghistory copied to clipboard
Fix `_generate_history_field()` for `BigAutoField`
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