mirror of
https://github.com/django/django.git
synced 2025-10-06 08:40:42 +00:00
Replaced DatabaseCreation sql methods by schema editor equivalents
Also used schema editor in migrate to sync unmigrated apps (sync_apps). Refs #22340. Thanks Tim Graham for the review.
This commit is contained in:
parent
15ba0d166f
commit
30cbd5d360
6 changed files with 54 additions and 70 deletions
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import re
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.management.color import no_style
|
||||
|
@ -10,6 +11,7 @@ from django.core.management.sql import (sql_create, sql_delete, sql_indexes,
|
|||
from django.db import connections, DEFAULT_DB_ALIAS
|
||||
from django.test import TestCase, override_settings
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
|
||||
# See also initial_sql_regress for 'custom_sql_for_model' tests
|
||||
|
||||
|
@ -67,7 +69,9 @@ class SQLCommandsTestCase(TestCase):
|
|||
|
||||
def test_sql_indexes(self):
|
||||
app_config = apps.get_app_config('commands_sql')
|
||||
output = sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", category=RemovedInDjango20Warning)
|
||||
output = sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
# PostgreSQL creates one additional index for CharField
|
||||
self.assertIn(self.count_ddl(output, 'CREATE INDEX'), [3, 4])
|
||||
|
||||
|
@ -79,7 +83,9 @@ class SQLCommandsTestCase(TestCase):
|
|||
|
||||
def test_sql_all(self):
|
||||
app_config = apps.get_app_config('commands_sql')
|
||||
output = sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", category=RemovedInDjango20Warning)
|
||||
output = sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
|
||||
self.assertEqual(self.count_ddl(output, 'CREATE TABLE'), 3)
|
||||
# PostgreSQL creates one additional index for CharField
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue