﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8331	manage.py sqlclear and friends crash, for unknown reasons	Dougal Sutherland	nobody	"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)."		closed	Core (Management commands)	dev		fixed			Unreviewed	0	0	0	0	0	0
