Hey,
Getting a bit of a corner case and wondering what you guys think.
So I’m importing fixtures, say this test.json
:
[
{
"model": "admin_account.terme",
"pk": 0,
"fields":
{
"desc_fr": "Net 30 jours",
"desc_en": "30 days net",
}
}
]
with model
class Terme(models.Model):
desc_fr = models.CharField(max_length=25, verbose_name='Desc_fr', blank=True, null=True)
desc_en = models.CharField(max_length=25, verbose_name='Desc_en', blank=True, null=True)
If I import it as-is, I get:
Traceback (most recent call last):
File "/home/fv/Documents/pro-2020/voltec/VOLTEC-PROJECT/VOLTEC-WEBAPP/app/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
psycopg2.errors.NumericValueOutOfRange: setval: value 0 is out of bounds for sequence "admin_account_terme_id_seq" (1..2147483647)
However, if I simply add another fixture, even in the same import, with id=0, then the importation works just fine.
I know from the doc that the default id field is AutoField, and at least SmallAutofield and BigAutoField mention values from 1…XXXXX.
The data I’m importing does contain a few id=0, and in the db they typically refer to unknown/missing/placeholder stuff. I am not 100% certain that I can just re-assign another id to that field, as perhaps other services expect this behavior.
So… am I likely fine to import id=0? Or should I take the issue to mean I need to find another way to do things?