summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-08-05 15:52:11 -0400
committerTim Graham <timograham@gmail.com>2015-08-20 08:14:16 -0400
commit333cbdcd2de4546e33ad50ebd8b67e1a1e87aeec (patch)
treef2cc68bc4557f9e5fa560f1214735c9e97039959 /django/db/models/sql
parent1b8d7eff3bb1de1f0b51137d720d6fcf7622bced (diff)
Fixed #24951 -- Fixed AssertionError in delete queries involving a foreign/primary key.
Thanks Anssi Kääriäinen for help.
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/compiler.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 9d89269ee6..8b841f6d5e 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -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])]