#32689: Infinite AlterField Migrations due to default callable object missmatch
-------------------------------------+-------------------------------------
Reporter: Samuel Bishop | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Resolution:
Keywords: infinite, | Triage Stage:
makemigrations, migrations, | Unreviewed
callable, default, field |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Pablo):
I was able to "reproduce" using sqlite as a DB backend with the following
model:
{{{
from ulid.api import new as new_ulid
from django.db import models
# Create your models here.
class SampleModel(models.Model):
ulid = models.CharField(
max_length=255,
null=False,
default=new_ulid
)
def __str__(self):
return str(self.ulid)
}}}
It's important to mention that the created migration is useless. It cannot
be applied due to an exception calling new_ulid: TypeError: new() missing
1 required positional argument: 'self'.
Might be related to the fact that new() is an instance method:
https://github.com/ahawker/ulid/blob/96bdb1daad7ce96f6db8c91ac0410b66d2e1c4c1/ulid/api/api.py#L51
If you create a proxy function, the migration is created and applied
correctly:
{{{
from ulid.api import new as new_ulid
from django.db import models
def ulid_proxy():
return new_ulid()
# Create your models here.
class SampleModel(models.Model):
ulid = models.CharField(
max_length=255,
null=False,
default=ulid_proxy
)
def __str__(self):
return str(self.ulid)
}}}
So I'm not sure if this is a bug related on how migrations are created or
if this is has something to do with how new() is implemented in ulid.api
--
Ticket URL: <https://code.djangoproject.com/ticket/32689#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.6e363d39f52c58b67592f5601ede1788%40djangoproject.com.