#23315 closed Bug (fixed)
Cannot resolve operation dependencies
Reported by: | Gabe Jackson | Owned by: | Tim Graham |
---|---|---|---|
Component: | Migrations | Version: | 1.7-rc-2 |
Severity: | Release blocker | Keywords: | migrations, autodetector, circular dependency |
Cc: | cmawebsite@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Change History (12)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
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.
comment:3 by , 10 years ago
I've reproduced the project from scratch just to be sure. Here are the simple models: https://github.com/collinanderson/ticket23315/commit/39c36c953e96a9eede4f77e161ee3bf96a3ded7b
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
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).
comment:7 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I'm looking into this. It seems to be a non-deterministic issue, perhaps ordering related.
comment:8 by , 10 years ago
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.
comment:11 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
do_pending_lookups
wasn't resolving the field due to a case mismatch.
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..