Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/_utils/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,14 @@ CREATE TABLE `update_only_fields_employee_account` (
UNIQUE KEY (`employee_id`, `account_id`),
KEY (`employee_id`),
KEY (`account_id`)
);
);

-- 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`)
);
16 changes: 14 additions & 2 deletions tests/contenttypes_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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"
Loading