Code

Ticket #12428: 12428.diff

File 12428.diff, 2.4 KB (added by simon, 4 years ago)

Patch from Alex Gaynor

Line 
1diff --git a/django/db/__init__.py b/django/db/__init__.py
2index 2971b67..3771463 100644
3--- a/django/db/__init__.py
4+++ b/django/db/__init__.py
5@@ -17,6 +17,9 @@ if not settings.DATABASES:
6         "settings.DATABASE_* is deprecated; use settings.DATABASES instead.",
7         PendingDeprecationWarning
8     )
9+   
10+    if not settings.DATABASE_ENGINE:
11+        settings.DATABASE_ENGINE = "dummy"
12 
13     settings.DATABASES[DEFAULT_DB_ALIAS] = {
14         'ENGINE': settings.DATABASE_ENGINE,
15@@ -35,7 +38,7 @@ if DEFAULT_DB_ALIAS not in settings.DATABASES:
16     raise ImproperlyConfigured("You must default a '%s' database" % DEFAULT_DB_ALIAS)
17 
18 for alias, database in settings.DATABASES.items():
19-    if database['ENGINE'] in ("postgresql", "postgresql_psycopg2", "sqlite3", "mysql", "oracle"):
20+    if database['ENGINE'] in ("postgresql", "postgresql_psycopg2", "sqlite3", "mysql", "oracle", "dummy", ""):
21         import warnings
22         if 'django.contrib.gis' in settings.INSTALLED_APPS:
23             warnings.warn(
24@@ -51,6 +54,8 @@ for alias, database in settings.DATABASES.items():
25             else:
26                 full_engine = 'django.contrib.gis.db.backends.%s' % database['ENGINE']
27         else:
28+            if not database['ENGINE']:
29+                database['ENGINE'] = 'dummy'
30             warnings.warn(
31                 "Short names for ENGINE in database configurations are deprecated. "
32                 "Prepend %s.ENGINE with 'django.db.backends.'" % alias,
33@@ -58,6 +63,8 @@ for alias, database in settings.DATABASES.items():
34             )
35             full_engine = "django.db.backends.%s" % database['ENGINE']
36         database['ENGINE'] = full_engine
37+    elif database['ENGINE'] == "django.db.backends.":
38+        database['ENGINE'] = "django.db.backends.dummy"
39 
40 connections = ConnectionHandler(settings.DATABASES)
41 
42diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py
43index e3ab456..c8bf4c0 100644
44--- a/django/db/backends/dummy/base.py
45+++ b/django/db/backends/dummy/base.py
46@@ -47,7 +47,8 @@ class DatabaseWrapper(object):
47         self.client = DatabaseClient(self)
48         self.creation = BaseDatabaseCreation(self)
49         self.introspection = DatabaseIntrospection(self)
50-        self.validation = BaseDatabaseValidation()
51+        self.validation = BaseDatabaseValidation(self)
52+        self.settings_dict = args[0]
53 
54     def close(self):
55         pass