diff --git a/TODO b/TODO index 6e7a09b197..82fdfcd9f4 100644 --- a/TODO +++ b/TODO @@ -11,15 +11,6 @@ Required for v1.2 * validate() on a field * name/purpose clash with Honza? * any overlap with existing methods? - * Check test failures with old-style (non-multi-db) settings file - * custom_pk - * backends - * Check test failures with MySQL MyISAM - * serializers_regress - * fixtures - * lookup - * transactions - * model_regress Optional for v1.2 ~~~~~~~~~~~~~~~~~ diff --git a/django/db/__init__.py b/django/db/__init__.py index a31c2bd6fc..358b431457 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -17,19 +17,9 @@ if not settings.DATABASES: "settings.DATABASE_* is deprecated; use settings.DATABASES instead.", PendingDeprecationWarning ) - - if settings.DATABASE_ENGINE in ("postgresql", "postgresql_psycopg2", - "sqlite3", "mysql", "oracle"): - engine = "django.db.backends.%s" % settings.DATABASE_ENGINE - warnings.warn( - "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'", - PendingDeprecationWarning - ) - else: - engine = settings.DATABASE_ENGINE settings.DATABASES[DEFAULT_DB_ALIAS] = { - 'ENGINE': engine, + 'ENGINE': settings.DATABASE_ENGINE, 'HOST': settings.DATABASE_HOST, 'NAME': settings.DATABASE_NAME, 'OPTIONS': settings.DATABASE_OPTIONS, @@ -44,6 +34,15 @@ if not settings.DATABASES: if DEFAULT_DB_ALIAS not in settings.DATABASES: raise ImproperlyConfigured("You must default a '%s' database" % DEFAULT_DB_ALIAS) +for database in settings.DATABASES.values(): + if database['ENGINE'] in ("postgresql", "postgresql_psycopg2", "sqlite3", "mysql", "oracle"): + database['ENGINE'] = "django.db.backends.%s" % database['ENGINE'] + import warnings + warnings.warn( + "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'", + PendingDeprecationWarning + ) + connections = ConnectionHandler(settings.DATABASES) diff --git a/django/db/utils.py b/django/db/utils.py index 087c414ae6..75ac5726ca 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -6,7 +6,13 @@ from django.utils.importlib import import_module def load_backend(backend_name): try: - return import_module('.base', 'django.db.backends.%s' % backend_name) + module = import_module('.base', 'django.db.backends.%s' % backend_name) + import warnings + warnings.warn( + "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'", + PendingDeprecationWarning + ) + return module except ImportError, e: # Look for a fully qualified database backend name try: