[Django] #22527: FK proxy model not properly deferred in syncdb

8 views
Skip to first unread message

Django

unread,
Apr 27, 2014, 9:12:27 AM4/27/14
to django-...@googlegroups.com
#22527: FK proxy model not properly deferred in syncdb
-------------------------------+--------------------------------------
Reporter: leftmoose | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords: proxy model, constraints
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Setup:

{{{
#!python
installed_apps = (
...
app1, app2, app3
)

db: postgres (to enfoce constraints)

app1.models:
from django.db import models

class Model1(models.Model):
foreign2 = models.ForeignKey('app2.Model2')

app2.models:
from app3.models import Model3

class Model2(Model3):
class Meta:
proxy = True

app3.models:
from django.db import models

# Create your models here.
class Model3(models.Model):
pass
}}}

{{{
#!bash
$ ./manage.py test -v2 app1


Creating test database for alias 'default' ('test_proxy_model_bug')...
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table app1_model1
Creating table app3_model3
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File
"/Users/david/dev/django_source/django/core/management/__init__.py", line
397, in execute_from_command_line
utility.execute()
File
"/Users/david/dev/django_source/django/core/management/__init__.py", line
390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/Users/david/dev/django_source/django/core/management/commands/test.py",
line 51, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/Users/david/dev/django_source/django/core/management/base.py",
line 240, in run_from_argv
self.execute(*args, **options.__dict__)
File
"/Users/david/dev/django_source/django/core/management/commands/test.py",
line 72, in execute
super(Command, self).execute(*args, **options)
File "/Users/david/dev/django_source/django/core/management/base.py",
line 283, in execute
output = self.handle(*args, **options)
File
"/Users/david/dev/django_source/django/core/management/commands/test.py",
line 89, in handle
failures = test_runner.run_tests(test_labels)
File "/Users/david/dev/django_source/django/test/runner.py", line 145,
in run_tests
old_config = self.setup_databases()
File "/Users/david/dev/django_source/django/test/runner.py", line 107,
in setup_databases
return setup_databases(self.verbosity, self.interactive, **kwargs)
File "/Users/david/dev/django_source/django/test/runner.py", line 279,
in setup_databases
verbosity, autoclobber=not interactive)
File "/Users/david/dev/django_source/django/db/backends/creation.py",
line 339, in create_test_db
load_initial_data=False)
File
"/Users/david/dev/django_source/django/core/management/__init__.py", line
159, in call_command
return klass.execute(*args, **defaults)
File "/Users/david/dev/django_source/django/core/management/base.py",
line 283, in execute
output = self.handle(*args, **options)
File "/Users/david/dev/django_source/django/core/management/base.py",
line 413, in handle
return self.handle_noargs(**options)
File
"/Users/david/dev/django_source/django/core/management/commands/syncdb.py",
line 107, in handle_noargs
cursor.execute(statement)
File "/Users/david/dev/django_source/django/db/utils.py", line 105, in
inner
return func(*args, **kwargs)
File "/Users/david/dev/django_source/django/db/utils.py", line 99, in
__exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/david/dev/django_source/django/db/utils.py", line 105, in
inner
return func(*args, **kwargs)
django.db.utils.ProgrammingError: relation "app3_model3" does not exist
}}}

git bisect reveals that this started happening in

{{{
196cc875b26f266e8f8dfd5be9daa0b8f246b9cd is the first bad commit
commit 196cc875b26f266e8f8dfd5be9daa0b8f246b9cd
Author: Tim Graham <timog...@gmail.com>
Date: Thu Aug 1 14:09:47 2013 -0400

[1.6.x] Fixed #17519 -- Fixed missing SQL constraints to proxy models.

Thanks thibaultj for the report, jenh for the patch,
and charettes for the tests.

Backport of aa830009de from master
}}}

so i guess this may be considered an improvement :p

from some pdb digging, it looks like the issue is that once the proxy
model `Model2` is created (but before the concrete one `Model3` is),
`syncdb` tries to setup all deferred constraints, though in this case, the
dependency is on `Model3`, not `Model2`.

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

Django

unread,
Apr 29, 2014, 6:44:41 PM4/29/14
to django-...@googlegroups.com
#22527: FK proxy model not properly deferred in syncdb
-------------------------------------+-------------------------------------
Reporter: leftmoose | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: proxy model, | Needs documentation: 0
constraints | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* cc: timo (added)
* needs_better_patch: => 0
* component: Uncategorized => Database layer (models, ORM)
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


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

Django

unread,
Oct 1, 2015, 1:08:56 PM10/1/15
to django-...@googlegroups.com
#22527: FK proxy model not properly deferred in syncdb
-------------------------------------+-------------------------------------
Reporter: leftmoose | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: proxy model, | Triage Stage: Accepted
constraints |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

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


Comment:

This doesn't appear to be an issue when using migrations.

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

Reply all
Reply to author
Forward
0 new messages