diff options
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 671e1234ff..8e868dfb0e 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2267,6 +2267,31 @@ class SchemaTests(TransactionTestCase): cast_function=lambda x: x.time(), ) + @isolate_apps('schema') + def test_namespaced_db_table_create_index_name(self): + """ + Table names are stripped of their namespace/schema before being used to + generate index names. + """ + with connection.schema_editor() as editor: + max_name_length = connection.ops.max_name_length() or 200 + namespace = 'n' * max_name_length + table_name = 't' * max_name_length + + class TableName(Model): + class Meta: + app_label = 'schema' + db_table = table_name + + class NameSpacedTableName(Model): + class Meta: + app_label = 'schema' + db_table = '"%s"."%s"' % (namespace, table_name) + self.assertEqual( + editor._create_index_name(TableName, []), + editor._create_index_name(NameSpacedTableName, []), + ) + @unittest.skipUnless(connection.vendor == 'oracle', 'Oracle specific db_table syntax') def test_creation_with_db_table_double_quotes(self): oracle_user = connection.creation._test_database_user() |
