summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-12-05 21:11:20 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2017-12-05 22:52:42 +0100
commit1decd0197d241b27d54bb12eca04b7e89a9ccba6 (patch)
tree657bb670845a295e4f59c42d23d662a92e6c6830 /django
parent3e52fd7595f80ec162fc44798c29399b7e899b9b (diff)
[1.11.x] Refs #28876 -- Fixed incorrect foreign key constraint name for models with quoted db_table.
Thanks Simon Charette and Tim Graham for the review and Carlos E. C. Leite for the report. Backport of fc48047586a8f92262f55d9d2bfb976325844b23 from master
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/base/schema.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
index 2c9e016d11..8802476c07 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -951,7 +951,7 @@ class BaseDatabaseSchemaEditor(object):
def _create_fk_sql(self, model, field, suffix):
from_table = model._meta.db_table
from_column = field.column
- to_table = field.target_field.model._meta.db_table
+ _, to_table = split_identifier(field.target_field.model._meta.db_table)
to_column = field.target_field.column
suffix = suffix % {
"to_table": to_table,
@@ -962,7 +962,7 @@ class BaseDatabaseSchemaEditor(object):
"table": self.quote_name(from_table),
"name": self.quote_name(self._create_index_name(model, [from_column], suffix=suffix)),
"column": self.quote_name(from_column),
- "to_table": self.quote_name(to_table),
+ "to_table": self.quote_name(field.target_field.model._meta.db_table),
"to_column": self.quote_name(to_column),
"deferrable": self.connection.ops.deferrable_sql(),
}