1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #24951 -- Fixed AssertionError in delete queries involving a foreign/primary key.

Thanks Anssi Kääriäinen for help.
This commit is contained in:
Tim Graham
2015-08-05 15:52:11 -04:00
parent 1b8d7eff3b
commit 333cbdcd2d
4 changed files with 13 additions and 4 deletions

View File

@@ -995,7 +995,7 @@ class SQLDeleteCompiler(SQLCompiler):
Creates the SQL for this query. Returns the SQL string and list of
parameters.
"""
assert len(self.query.tables) == 1, \
assert len([t for t in self.query.tables if self.query.alias_refcount[t] > 0]) == 1, \
"Can only delete from one table at a time."
qn = self.quote_name_unless_alias
result = ['DELETE FROM %s' % qn(self.query.tables[0])]