Code

Opened 6 years ago

Closed 6 years ago

#8331 closed (fixed)

manage.py sqlclear and friends crash, for unknown reasons

Reported by: d00gs Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When I run manage.py sqlclear, it often crashes with the following traceback:

$ ./manage.py sqlclear tests
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 334, in execute_manager
    utility.execute()
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 96, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 146, in handle
    app_output = self.handle_app(app, **options)
  File "/Library/Python/2.5/site-packages/django/core/management/commands/sqlclear.py", line 10, in handle_app
    return u'\n'.join(sql_delete(app, self.style)).encode('utf-8')
  File "/Library/Python/2.5/site-packages/django/core/management/sql.py", line 98, in sql_delete
    output.extend(connection.creation.sql_destroy_model(model, references_to_delete, style))
  File "/Library/Python/2.5/site-packages/django/db/backends/creation.py", line 263, in sql_destroy_model
    output.extend(self.sql_remove_table_constraints(model, references_to_delete, style))
TypeError: sql_remove_table_constraints() takes exactly 3 arguments (4 given)

As far as I can tell, though, sql_remove_table_constraints() does actually want four arguments (including self).

An example for which this happens is a simple project, with only the one app installed, whose models.py looks like

from django.db import models

class Watcher(models.Model):
    user = models.ForeignKey('User')

class User(models.Model):
    pass

If you switch the order of the definitions, however, it works fine (outputting the appropriate DROP statements).

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

(In [8364]) Fixed #8331 -- Added style parameter to sqlite backend implementation of sql_remove_table_constraints, missed in recent db backend refactor. Thanks to d00gs for the report.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.