[Django] #23315: Cannot resolve operation dependencies

39 views
Skip to first unread message

Django

unread,
Aug 19, 2014, 6:04:52 AM8/19/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
gabejackson | Status: new
Type: Bug | Version: 1.7-rc-2
Component: | Keywords: migrations, autodetector, circular
Migrations | dependency
Severity: Release | Has patch: 0
blocker | UI/UX: 0
Triage Stage: |
Unreviewed |
Easy pickings: 0 |
-------------------------+-------------------------------------------------
The auto detector cannot create migrations for the project located at:
[https://github.com/gabejackson/django-migration-test]
Using Django==1.7c2 and python 2.7.5
The command used is:
{{{
./manage.py makemigrations --dry-run
}}}

which leads to:
{{{
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/core/management/base.py", line 337, in execute
output = self.handle(*args, **options)
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/core/management/commands/makemigrations.py", line 111, in
handle
convert_apps=app_labels or None,
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/db/migrations/autodetector.py", line 50, in changes
changes = self._detect_changes(convert_apps, graph)
File "/Users/gabejackson/venv/django-1.7/lib/python2.7/site-
packages/django/db/migrations/autodetector.py", line 288, in
_detect_changes
raise ValueError("Cannot resolve operation dependencies")
ValueError: Cannot resolve operation dependencies
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23315>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 19, 2014, 6:46:29 AM8/19/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage:
autodetector, circular dependency | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by gabejackson):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I further reduced the model to only 2 apps and 4 models. I found out that
the auto-detector is non-deterministic depending on the alphabetical names
of the models.
If you run the project with the class APackage it will fail with "Cannot
resolve operation deps". If you rename APackage to DPackage (DPackage is
alphabetically now later than DeliveryCountry) and run makemigrations
--dry-run again, it works...

Apparently there is some issue with sorting classes alphabetically. Hope
this helps..

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:1>

Django

unread,
Aug 19, 2014, 12:11:37 PM8/19/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by collinanderson):

* cc: cmawebsite@… (added)
* stage: Unreviewed => Accepted


Comment:

I get the same error with these simple models on the latest code. It's a
circular dependency of ForeignKeys between apps, and I don't see anything
saying that this isn't supported.

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:2>

Django

unread,
Aug 19, 2014, 12:19:37 PM8/19/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by collinanderson):

I've reproduced the project from scratch just to be sure. Here are the
simple models:
https://github.com/collinanderson/ticket23315/commit/39c36c953e96a9eede4f77e161ee3bf96a3ded7b

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:3>

Django

unread,
Aug 19, 2014, 10:52:00 PM8/19/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution: fixed

Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Andrew Godwin <andrew@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"9247da1032c1b8c98b0fcfb278bbbdbc8edc8783"]:
{{{
#!CommitTicketReference repository=""
revision="9247da1032c1b8c98b0fcfb278bbbdbc8edc8783"
Fixed #23315: Operational dependency fail with mixed create/add
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:4>

Django

unread,
Aug 19, 2014, 10:52:02 PM8/19/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution: fixed
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Andrew Godwin <andrew@…>):

In [changeset:"824e02bf836affa182dd4bcb7b3e1796f1389b38"]:
{{{
#!CommitTicketReference repository=""
revision="824e02bf836affa182dd4bcb7b3e1796f1389b38"
[1.7.x] Fixed #23315: Operational dependency fail with mixed create/add
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:5>

Django

unread,
Aug 20, 2014, 7:35:51 AM8/20/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: closed => new
* resolution: fixed =>


Comment:

The new test fails on Python 3.4:
{{{
======================================================================
ERROR [0.001s]: test_circular_dependency_mixed_addcreate
(migrations.test_autodetector.AutodetectorTests)
----------------------------------------------------------------------


Traceback (most recent call last):

File "/home/jenkins/workspace/django-
master/database/sqlite3/python/python3.4/tests/migrations/test_autodetector.py",
line 1099, in test_circular_dependency_mixed_addcreate
changes = autodetector._detect_changes()
File "/home/jenkins/workspace/django-
master/database/sqlite3/python/python3.4/django/db/migrations/autodetector.py",
line 172, in _detect_changes
self.generate_created_models()
File "/home/jenkins/workspace/django-
master/database/sqlite3/python/python3.4/django/db/migrations/autodetector.py",
line 497, in generate_created_models
dep_app_label = field.rel.to._meta.app_label
AttributeError: 'str' object has no attribute '_meta'
}}}
The string is `"a.person"` (but resolves to `<class 'Person'>` when the
test passes).

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:6>

Django

unread,
Aug 20, 2014, 12:46:11 PM8/20/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: timgraham
Type: Bug | Status: assigned

Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* owner: nobody => timgraham
* status: new => assigned


Comment:

I'm looking into this. It seems to be a non-deterministic issue, perhaps
ordering related.

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:7>

Django

unread,
Aug 20, 2014, 1:15:02 PM8/20/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: timgraham
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by andrewgodwin):

That's odd, because all the other relationships in that test file are fine
under 3.4. It's likely an issue in the State's reconstruction of it. Happy
to look at this instead if you want to hand it over.

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:8>

Django

unread,
Aug 20, 2014, 2:01:53 PM8/20/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: timgraham
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d1299fce0eeeb2a7749fecafc87260462e75aac9"]:
{{{
#!CommitTicketReference repository=""
revision="d1299fce0eeeb2a7749fecafc87260462e75aac9"
Fixed migrations tests added in refs #23315.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:9>

Django

unread,
Aug 20, 2014, 2:03:02 PM8/20/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: timgraham
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution:
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"6981eced83ea2d6462b21c12ecea044e02e56d05"]:
{{{
#!CommitTicketReference repository=""
revision="6981eced83ea2d6462b21c12ecea044e02e56d05"
[1.7.x] Fixed migrations tests added in refs #23315.

Backport of d1299fce0e from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:10>

Django

unread,
Aug 20, 2014, 2:06:37 PM8/20/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: timgraham
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution: fixed

Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: assigned => closed
* resolution: => fixed


Comment:

`do_pending_lookups` wasn't resolving the field due to a case mismatch.

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:11>

Django

unread,
Aug 21, 2014, 11:08:11 AM8/21/14
to django-...@googlegroups.com
#23315: Cannot resolve operation dependencies
-------------------------------------+-------------------------------------
Reporter: gabejackson | Owner: timgraham
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution: fixed
Keywords: migrations, | Triage Stage: Accepted
autodetector, circular dependency | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Andrew Godwin <andrew@…>):

In [changeset:"9247da1032c1b8c98b0fcfb278bbbdbc8edc8783"]:
{{{
#!CommitTicketReference repository=""
revision="9247da1032c1b8c98b0fcfb278bbbdbc8edc8783"


Fixed #23315: Operational dependency fail with mixed create/add
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23315#comment:12>

Reply all
Reply to author
Forward
0 new messages