[Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
----------------------------+--------------------
     Reporter:  sir-sigurd  |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.8
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 {{{
 class Person(models.Model):
     pass

 class Book(models.Model):
     author = models.ForeignKey(Person)
 }}}

 {{{
 class Person(models.Model):
     pass

 class Book(models.Model):
     author = models.ForeignKey(Person)

 class Reviewer(models.Model):
     pass

 class Review(models.Model):
     book = models.ForeignKey(Book)
 }}}

 {{{
 class Book(models.Model):
     pass

 class Reviewer(models.Model):
     pass

 class Review(models.Model):
     reviewer = models.ForeignKey(Reviewer)
     book = models.ForeignKey(Book)
 }}}


 {{{
 $ python manage.py squashmigrations test_app 0003
 $ python manage.py migrate test_app
 Applying test_app.0001_squashed_0003_auto_20160607_1120...Traceback (most
 recent call last):
   File "manage.py", line 22, in <module>
     execute_from_command_line(sys.argv)
   File "/home/sergey/dev/django/django/core/management/__init__.py", line
 354, in execute_from_command_line
     utility.execute()
   File "/home/sergey/dev/django/django/core/management/__init__.py", line
 346, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/sergey/dev/django/django/core/management/base.py", line 394,
 in run_from_argv
     self.execute(*args, **cmd_options)
   File "/home/sergey/dev/django/django/core/management/base.py", line 445,
 in execute
     output = self.handle(*args, **options)
   File
 "/home/sergey/dev/django/django/core/management/commands/migrate.py", line
 222, in handle
     executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
   File "/home/sergey/dev/django/django/db/migrations/executor.py", line
 110, in migrate
     self.apply_migration(states[migration], migration, fake=fake,
 fake_initial=fake_initial)
   File "/home/sergey/dev/django/django/db/migrations/executor.py", line
 148, in apply_migration
     state = migration.apply(state, schema_editor)
   File "/home/sergey/dev/django/django/db/migrations/migration.py", line
 115, in apply
     operation.database_forwards(self.app_label, schema_editor, old_state,
 project_state)
   File
 "/home/sergey/dev/django/django/db/migrations/operations/models.py", line
 59, in database_forwards
     schema_editor.create_model(model)
   File "/home/sergey/dev/django/django/db/backends/base/schema.py", line
 236, in create_model
     definition, extra_params = self.column_sql(model, field)
   File "/home/sergey/dev/django/django/db/backends/base/schema.py", line
 135, in column_sql
     db_params = field.db_parameters(connection=self.connection)
   File "/home/sergey/dev/django/django/db/models/fields/related.py", line
 2010, in db_parameters
     return {"type": self.db_type(connection), "check": []}
   File "/home/sergey/dev/django/django/db/models/fields/related.py", line
 2001, in db_type
     rel_field = self.related_field
   File "/home/sergey/dev/django/django/db/models/fields/related.py", line
 1904, in related_field
     return self.foreign_related_fields[0]
   File "/home/sergey/dev/django/django/db/models/fields/related.py", line
 1638, in foreign_related_fields
     return tuple(rhs_field for lhs_field, rhs_field in self.related_fields
 if rhs_field)
   File "/home/sergey/dev/django/django/db/models/fields/related.py", line
 1625, in related_fields
     self._related_fields = self.resolve_related_fields()
   File "/home/sergey/dev/django/django/db/models/fields/related.py", line
 1610, in resolve_related_fields
     raise ValueError('Related model %r cannot be resolved' % self.rel.to)
 ValueError: Related model u'test_app.Person' cannot be resolved
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26720>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/053.de8e19cafcb83b75df40c8d98798450e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
----------------------------+--------------------------------------
     Reporter:  sir-sigurd  |                    Owner:  sir-sigurd
         Type:  Bug         |                   Status:  assigned
    Component:  Migrations  |                  Version:  1.8
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Unreviewed
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------
Changes (by sir-sigurd):

 * status:  new => assigned
 * needs_better_patch:   => 0
 * owner:  nobody => sir-sigurd
 * needs_tests:   => 0
 * needs_docs:   => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:1>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.95c8dd23fe8c2e3daa84ee77c89396ea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
----------------------------+--------------------------------------
     Reporter:  sir-sigurd  |                    Owner:  sir-sigurd
         Type:  Bug         |                   Status:  assigned
    Component:  Migrations  |                  Version:  1.8
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Unreviewed
    Has patch:  1           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------
Changes (by sir-sigurd):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/6741 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.ec27d7da36b1f4ba21a88f1b153a6e72%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
----------------------------+--------------------------------------
     Reporter:  sir-sigurd  |                    Owner:  sir-sigurd
         Type:  Bug         |                   Status:  assigned
    Component:  Migrations  |                  Version:  1.8
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Accepted
    Has patch:  1           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------
Changes (by timgraham):

 * stage:  Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.25c780fed814156c7d85489da0a9c033%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fedoseev      |                    Owner:  Sergey
                                     |  Fedoseev
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:  1.8
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26720#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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.ae10bdd5fc6404a1fb775dd3ea2bd618%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fedoseev      |                    Owner:  Sergey
                                     |  Fedoseev
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * needs_better_patch:  1 => 0
 * version:  1.8 => master


Comment:

 New patch [https://github.com/django/django/pull/7999 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:5>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.172cd4a92025e1732093bbf002e04527%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
---------------------------------+------------------------------------
     Reporter:  Sergey Fedoseev  |                    Owner:  (none)
         Type:  Bug              |                   Status:  new
    Component:  Migrations       |                  Version:  master
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by Sergey Fedoseev):

 * owner:  Sergey Fedoseev => (none)
 * status:  assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:6>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.8201a0d421a25510cc021dbc3d14586e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
---------------------------------+------------------------------------
     Reporter:  Sergey Fedoseev  |                    Owner:  (none)
         Type:  Bug              |                   Status:  new
    Component:  Migrations       |                  Version:  master
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  1
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:7>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.7a3bae694e544bc6d02d99053d7b9494%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #26720: migration optimizer can produce operations that references removed models under certain circumstances

Django
In reply to this post by Django
#26720: migration optimizer can produce operations that references removed models
under certain circumstances
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fedoseev      |                    Owner:  Tim
                                     |  Graham <timograham@…>
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  master
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

 * owner:  (none) => Tim Graham <timograham@…>
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"ad82900ad94ed4bbad050b9993373dafbe66b610" ad82900a]:
 {{{
 #!CommitTicketReference repository=""
 revision="ad82900ad94ed4bbad050b9993373dafbe66b610"
 Fixed #26720 -- Prevented invalid CreateModel optimizations of related
 fields.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26720#comment:8>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.6bd95818fb0c1148b4a5c1a7fd54ce3c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.