summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-05-23 15:09:35 +0200
committerTim Graham <timograham@gmail.com>2017-05-23 09:09:35 -0400
commitb3eb6eaf1a197ff155faf333871da032c77ba855 (patch)
tree185f965059811b862e4a0f4372a3db4918911beb
parent5dc6f77423084dd7c99549b1e477ee573802f5a4 (diff)
Refs #27859 -- Added DatabaseWrapper.display_name.
Thanks Tim Graham for the review.
-rw-r--r--django/db/backends/base/base.py1
-rw-r--r--django/db/backends/mysql/base.py1
-rw-r--r--django/db/backends/oracle/base.py1
-rw-r--r--django/db/backends/postgresql/base.py1
-rw-r--r--django/db/backends/sqlite3/base.py1
-rw-r--r--docs/releases/2.0.txt4
-rw-r--r--tests/backends/tests.py4
7 files changed, 13 insertions, 0 deletions
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py
index 5baff6a34a..660542c095 100644
--- a/django/db/backends/base/base.py
+++ b/django/db/backends/base/base.py
@@ -31,6 +31,7 @@ class BaseDatabaseWrapper:
data_type_check_constraints = {}
ops = None
vendor = 'unknown'
+ display_name = 'unknown'
SchemaEditorClass = None
# Classes instantiated in __init__().
client_class = None
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 08632a0ec5..f32dee09a8 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -103,6 +103,7 @@ class CursorWrapper:
class DatabaseWrapper(BaseDatabaseWrapper):
vendor = 'mysql'
+ display_name = 'MySQL'
# This dictionary maps Field objects to their associated MySQL column
# types, as strings. Column-type strings can contain format strings; they'll
# be interpolated against the values of Field.__dict__ before being output.
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 65aac70b9e..fb49fc5ffb 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -72,6 +72,7 @@ class _UninitializedOperatorsDescriptor:
class DatabaseWrapper(BaseDatabaseWrapper):
vendor = 'oracle'
+ display_name = 'Oracle'
# This dictionary maps Field objects to their associated Oracle column
# types, as strings. Column-type strings can contain format strings; they'll
# be interpolated against the values of Field.__dict__ before being output.
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index dd20656c3b..15adb0282e 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -59,6 +59,7 @@ psycopg2.extensions.register_type(INETARRAY)
class DatabaseWrapper(BaseDatabaseWrapper):
vendor = 'postgresql'
+ display_name = 'PostgreSQL'
# This dictionary maps Field objects to their associated PostgreSQL column
# types, as strings. Column-type strings can contain format strings; they'll
# be interpolated against the values of Field.__dict__ before being output.
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 7806402055..5892de92f8 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -45,6 +45,7 @@ Database.register_adapter(decimal.Decimal, backend_utils.rev_typecast_decimal)
class DatabaseWrapper(BaseDatabaseWrapper):
vendor = 'sqlite'
+ display_name = 'SQLite'
# SQLite doesn't actually support most of these types, but it "does the right
# thing" given more verbose field definitions, so leave them as is so that
# schema inspection is more useful.
diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt
index 0411e8fb2d..186f64319d 100644
--- a/docs/releases/2.0.txt
+++ b/docs/releases/2.0.txt
@@ -258,6 +258,10 @@ Database backend API
``datetime_extract_sql()`` methods now return only the SQL to perform the
operation instead of SQL and a list of parameters.
+* Third-party database backends should add a ``DatabaseWrapper.display_name``
+ attribute with the name of the database that your backend works with. Django
+ may use it in various messages, such as in system checks.
+
Dropped support for Oracle 11.2
-------------------------------
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 7853d02a24..7ea11b846f 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -55,6 +55,10 @@ class DatabaseWrapperTests(SimpleTestCase):
instance_attr_value = getattr(conn, instance_attr_name)
self.assertIsInstance(instance_attr_value, class_attr_value)
+ def test_initialization_display_name(self):
+ self.assertEqual(BaseDatabaseWrapper.display_name, 'unknown')
+ self.assertNotEqual(connection.display_name, 'unknown')
+
class DummyBackendTest(SimpleTestCase):