summaryrefslogtreecommitdiff
path: root/tests/model_indexes
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-12-05 21:05:10 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2017-12-05 21:05:10 +0100
commitf79d9a322c6008e5fada1453aebfb56afc316cc8 (patch)
tree9456db8f19e70b047ceb2a7c63ff8d1cf1983bb2 /tests/model_indexes
parentf2ec89691236b59f54f9cf41bccd79a5853af36c (diff)
downloaddjango-f79d9a322c6008e5fada1453aebfb56afc316cc8.tar.gz
Refs #28876 -- Fixed incorrect class-based model index name generation for models with quoted db_table.
Thanks Simon Charette and Tim Graham for the review and Carlos E. C. Leite for the report.
Diffstat (limited to 'tests/model_indexes')
-rw-r--r--tests/model_indexes/tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/model_indexes/tests.py b/tests/model_indexes/tests.py
index 5f1743439c..28759dbe80 100644
--- a/tests/model_indexes/tests.py
+++ b/tests/model_indexes/tests.py
@@ -1,6 +1,7 @@
from django.conf import settings
from django.db import connection, models
from django.test import SimpleTestCase, skipUnlessDBFeature
+from django.test.utils import isolate_apps
from .models import Book, ChildModel1, ChildModel2
@@ -70,6 +71,18 @@ class IndexesTests(SimpleTestCase):
with self.assertRaisesMessage(AssertionError, msg):
long_field_index.set_name_with_model(Book)
+ @isolate_apps('model_indexes')
+ def test_name_auto_generation_with_quoted_db_table(self):
+ class QuotedDbTable(models.Model):
+ name = models.CharField(max_length=50)
+
+ class Meta:
+ db_table = '"t_quoted"'
+
+ index = models.Index(fields=['name'])
+ index.set_name_with_model(QuotedDbTable)
+ self.assertEqual(index.name, 't_quoted_name_e4ed1b_idx')
+
def test_deconstruction(self):
index = models.Index(fields=['title'], db_tablespace='idx_tbls')
index.set_name_with_model(Book)