Opened 12 years ago
Closed 12 years ago
#18297 closed Bug (duplicate)
Reverse generic relation to a model inheriting from the model defining a generic relation confuses flush
Reported by: | pronik | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Please look into attached file, I've created a minimal test project for this bug. You'll have to include your database credentials in settings.py
before you try it.
Let's say we have model with a generic relation (e.g. django.contrib.comments.models.Comment
) and a model deriving from it (e.g. OtherComment
). Now, if a reverse generic relation to OtherComment
is defined, it would correctly work and point to a list of OtherComment
instances. However, flush
would now try to reset the sequence on id
field of OtherComment
which does not exist (OtherComment
only has comment_ptr_id
) while resetting id
on Comment
would be correct.
Attachments (1)
Change History (4)
by , 12 years ago
Attachment: | djangobug.zip added |
---|
comment:1 by , 12 years ago
Forgot to mention: this is on PostgreSQL 9.1, however, I assume this bug could be relevant for other DBMS.
comment:2 by , 12 years ago
Component: | Uncategorized → Core (Management commands) |
---|---|
Triage Stage: | Unreviewed → Accepted |
In addition to configuring a database, you'll have to add 'django.contrib.comments'
to INSTALLED_APPS
for the provided project to work.
Here's the traceback:
(django-dev)myk@mYk djangobug % python manage.py syncdb Creating tables ... Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table django_comments Creating table django_comment_flags Creating table django_content_type Creating table django_session Creating table django_site Creating table my_comments_othercomment Creating table my_comments_somethingcommented You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): no Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s)
(django-dev)myk@mYk djangobug % python manage.py flush --traceback You have requested a flush of the database. This will IRREVERSIBLY DESTROY all data currently in the 'throwaway' database, and return each table to the state it was in after syncdb. Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes Traceback (most recent call last): File "/Users/myk/Documents/dev/django-trunk/django/core/management/base.py", line 222, in run_from_argv self.execute(*args, **options.__dict__) File "/Users/myk/Documents/dev/django-trunk/django/core/management/base.py", line 252, in execute output = self.handle(*args, **options) File "/Users/myk/Documents/dev/django-trunk/django/core/management/base.py", line 382, in handle return self.handle_noargs(**options) File "/Users/myk/Documents/dev/django-trunk/django/core/management/commands/flush.py", line 67, in handle_noargs The full error: %s""" % (connection.settings_dict['NAME'], e)) CommandError: Database throwaway couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run. The full error: column "id" of relation "my_comments_othercomment" does not exist CommandError: Database throwaway couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run. The full error: column "id" of relation "my_comments_othercomment" does not exist
comment:3 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
I'm going to close this as a duplicate of #13203 that now is about this same issue.
Minimal project reproducing the problem