Fixed #30071 -- Fixed error message when a 'default' database isn't provided.
This commit is contained in:
parent
c2c85663e2
commit
222caab68a
|
@ -151,11 +151,10 @@ class ConnectionHandler:
|
||||||
'ENGINE': 'django.db.backends.dummy',
|
'ENGINE': 'django.db.backends.dummy',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if DEFAULT_DB_ALIAS not in self._databases:
|
||||||
|
raise ImproperlyConfigured("You must define a '%s' database." % DEFAULT_DB_ALIAS)
|
||||||
if self._databases[DEFAULT_DB_ALIAS] == {}:
|
if self._databases[DEFAULT_DB_ALIAS] == {}:
|
||||||
self._databases[DEFAULT_DB_ALIAS]['ENGINE'] = 'django.db.backends.dummy'
|
self._databases[DEFAULT_DB_ALIAS]['ENGINE'] = 'django.db.backends.dummy'
|
||||||
|
|
||||||
if DEFAULT_DB_ALIAS not in self._databases:
|
|
||||||
raise ImproperlyConfigured("You must define a '%s' database" % DEFAULT_DB_ALIAS)
|
|
||||||
return self._databases
|
return self._databases
|
||||||
|
|
||||||
def ensure_defaults(self, alias):
|
def ensure_defaults(self, alias):
|
||||||
|
|
|
@ -31,6 +31,13 @@ class ConnectionHandlerTests(SimpleTestCase):
|
||||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||||
conns[DEFAULT_DB_ALIAS].ensure_connection()
|
conns[DEFAULT_DB_ALIAS].ensure_connection()
|
||||||
|
|
||||||
|
def test_no_default_database(self):
|
||||||
|
DATABASES = {'other': {}}
|
||||||
|
conns = ConnectionHandler(DATABASES)
|
||||||
|
msg = "You must define a 'default' database."
|
||||||
|
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||||
|
conns['other'].ensure_connection()
|
||||||
|
|
||||||
|
|
||||||
class DatabaseErrorWrapperTests(TestCase):
|
class DatabaseErrorWrapperTests(TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue