#31392: Avoid getting the model field default value during migrations if there 
is
not a change from NULL to NOT NULL
-----------------------------------------+------------------------
               Reporter:  Shipeng Feng   |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Migrations     |        Version:  master
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Example:


 {{{
 #!python
 def old_default_code():
     return 'old'

 def new_default_code():
     # running something that is stateful, for example, increase a database
 counter

 class Student(models.Model):
     code = models.CharField(default=new_default_code)
 }}}

 We change the default callable object, and run {{{manage.py migrate}}},
 ideally {{{new_default_code}}} shouldn't be
 called, however, we are getting the model field default value no matter
 whether we need it or not:

 
https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L679

 I'd love to send a pull request for this if necessary.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31392>
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/049.15c529819ea1cf0e47f828aa75088245%40djangoproject.com.

Reply via email to