diff options
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 074f252197..ad66f55650 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2999,6 +2999,35 @@ class SchemaTests(TransactionTestCase): student = Student.objects.create(name='Some man') doc.students.add(student) + @isolate_apps('schema') + @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific db_table syntax.') + def test_namespaced_db_table_foreign_key_reference(self): + with connection.cursor() as cursor: + cursor.execute('CREATE SCHEMA django_schema_tests') + + def delete_schema(): + with connection.cursor() as cursor: + cursor.execute('DROP SCHEMA django_schema_tests CASCADE') + + self.addCleanup(delete_schema) + + class Author(Model): + class Meta: + app_label = 'schema' + + class Book(Model): + class Meta: + app_label = 'schema' + db_table = '"django_schema_tests"."schema_book"' + + author = ForeignKey(Author, CASCADE) + author.set_attributes_from_name('author') + + with connection.schema_editor() as editor: + editor.create_model(Author) + editor.create_model(Book) + editor.add_field(Book, author) + def test_rename_table_renames_deferred_sql_references(self): atomic_rename = connection.features.supports_atomic_references_rename with connection.schema_editor(atomic=atomic_rename) as editor: |
