diff --git a/tests/_utils/setup.sql b/tests/_utils/setup.sql index 57e48d01ed4b..12ba2584a462 100644 --- a/tests/_utils/setup.sql +++ b/tests/_utils/setup.sql @@ -418,4 +418,14 @@ CREATE TABLE `update_only_fields_employee_account` ( UNIQUE KEY (`employee_id`, `account_id`), KEY (`employee_id`), KEY (`account_id`) -); \ No newline at end of file +); + +-- contenttypes_tests +CREATE TABLE `contenttypes_tests_modelwithm2mtosite_site` ( + `modelwithm2mtosite_id` BIGINT NOT NULL, + `site_id` BIGINT NOT NULL, + SHARD KEY (`modelwithm2mtosite_id`), + UNIQUE KEY (`modelwithm2mtosite_id`, `site_id`), + KEY (`modelwithm2mtosite_id`), + KEY (`site_id`) +); diff --git a/tests/contenttypes_tests/models.py b/tests/contenttypes_tests/models.py index 5e40217c308c..98c762879d84 100644 --- a/tests/contenttypes_tests/models.py +++ b/tests/contenttypes_tests/models.py @@ -5,6 +5,8 @@ from django.contrib.sites.models import SiteManager from django.db import models +from django_singlestore.schema import ModelStorageManager + class Site(models.Model): domain = models.CharField(max_length=100) @@ -46,9 +48,10 @@ class FooWithoutUrl(models.Model): Fake model not defining ``get_absolute_url`` for ContentTypesTests.test_shortcut_view_without_get_absolute_url() """ - name = models.CharField(max_length=30, unique=True) + objects = ModelStorageManager("REFERENCE") + class FooWithUrl(FooWithoutUrl): """ @@ -108,7 +111,16 @@ def get_absolute_url(self): class ModelWithM2MToSite(models.Model): title = models.CharField(max_length=200) - sites = models.ManyToManyField(Site) + sites = models.ManyToManyField("Site", through="ModelWithM2MToSiteSite") def get_absolute_url(self): return "/title/%s/" % quote(self.title) + + +class ModelWithM2MToSiteSite(models.Model): + modelwithm2mtosite = models.ForeignKey(ModelWithM2MToSite, on_delete=models.CASCADE) + site = models.ForeignKey(Site, on_delete=models.CASCADE) + + class Meta: + unique_together = (('modelwithm2mtosite', 'site'),) + db_table = "contenttypes_tests_modelwithm2mtosite_site"