Ticket #12308: t12308_3.diff
File t12308_3.diff, 3.5 KB (added by , 14 years ago) |
---|
-
django/db/backends/postgresql/operations.py
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index f517436..1f5fb6e 100644
a b class DatabaseOperations(BaseDatabaseOperations): 133 133 style.SQL_TABLE(qn(f.m2m_db_table())))) 134 134 return output 135 135 136 def tablespace_sql(self, tablespace, inline=False): 137 return "%sTABLESPACE %s" % ((inline and "USING INDEX " or ""), 138 self.quote_name(tablespace)) 139 136 140 def savepoint_create_sql(self, sid): 137 141 return "SAVEPOINT %s" % sid 138 142 -
new file tests/modeltests/tablespaces/tablespaces_app/models.py
diff --git a/tests/modeltests/tablespaces/__init__.py b/tests/modeltests/tablespaces/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/modeltests/tablespaces/models.py b/tests/modeltests/tablespaces/models.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/modeltests/tablespaces/tablespaces_app/__init__.py b/tests/modeltests/tablespaces/tablespaces_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/modeltests/tablespaces/tablespaces_app/models.py b/tests/modeltests/tablespaces/tablespaces_app/models.py new file mode 100644 index 0000000..947a0b2
- + 1 from django.db import models 2 3 class TestModel1(models.Model): 4 """ 5 Model with overriden tablespace 6 """ 7 name = models.CharField(max_length=255, default='') 8 9 class Meta: 10 db_tablespace = "custom1" 11 12 class TestModel2(models.Model): 13 """ 14 Model with default tablespace 15 """ 16 name = models.CharField(max_length=255, default='') -
new file tests/modeltests/tablespaces/tests.py
diff --git a/tests/modeltests/tablespaces/tests.py b/tests/modeltests/tablespaces/tests.py new file mode 100644 index 0000000..ba8ff05
- + 1 from django.core.management import call_command 2 from django.test import TestCase 3 from django.conf import settings 4 from django.db import DEFAULT_DB_ALIAS 5 from django.db import connections, DEFAULT_DB_ALIAS 6 from django.core.management.color import no_style 7 8 if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].startswith('django.db.backends.postgresql'): 9 class TablespacesTests(TestCase): 10 11 def setUp(self): 12 self.old_default_tablespace = settings.DEFAULT_TABLESPACE 13 settings.DEFAULT_TABLESPACE = "custom" 14 self.connection = connections[DEFAULT_DB_ALIAS] 15 self.style = no_style() 16 17 def tearDown(self): 18 settings.DEFAULT_TABLESPACE = self.old_default_tablespace 19 20 def test_overriden_tablespace(self): 21 from modeltests.tablespaces.tablespaces_app.models import TestModel1 22 result = self.connection.creation.sql_create_model(TestModel1, self.style, set([])) 23 self.assertEqual(result[0][0], 'CREATE TABLE "tablespaces_app_testmodel1" (\n "id" serial NOT NULL PRIMARY KEY USING INDEX TABLESPACE "custom1",\n "name" varchar(255) NOT NULL\n)\nTABLESPACE "custom1"\n;') 24 25 def test_default_tablespace(self): 26 from modeltests.tablespaces.tablespaces_app.models import TestModel2 27 result = self.connection.creation.sql_create_model(TestModel2, self.style, set([])) 28 self.assertEqual(result[0][0], 'CREATE TABLE "tablespaces_app_testmodel2" (\n "id" serial NOT NULL PRIMARY KEY USING INDEX TABLESPACE "custom",\n "name" varchar(255) NOT NULL\n)\nTABLESPACE "custom"\n;')