summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@oscaro.com>2014-06-05 17:56:56 +0200
committerAymeric Augustin <aymeric.augustin@oscaro.com>2014-06-05 17:57:48 +0200
commit342b25449d800ce29ae56ff8285869cbc3133a75 (patch)
tree4546e9c1097c7650f0d46a4108b5e3f281808dce
parent2e4bcb9b0265ceb0ef0eae6da2a91f89d037d05f (diff)
[1.7.x] Added a flag for the ability to introspect nullable fields.
Previously this was conflated with another Oracle-specific behavior. Backport of a03d38d from master.
-rw-r--r--django/db/backends/__init__.py3
-rw-r--r--django/db/backends/oracle/base.py1
-rw-r--r--tests/introspection/tests.py9
3 files changed, 8 insertions, 5 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 90d99b14cc..e3f6266574 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -663,6 +663,9 @@ class BaseDatabaseFeatures(object):
# Can the backend determine reliably the length of a CharField?
can_introspect_max_length = True
+ # Can the backend determine reliably if a field is nullable?
+ can_introspect_null = True
+
# Confirm support for introspected foreign keys
# Every database can do this reliably, except MySQL,
# which can't do it for MyISAM tables
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index de264a7b5b..f7790415db 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -112,6 +112,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_tablespaces = True
supports_sequence_reset = False
can_introspect_max_length = False
+ can_introspect_null = False
can_introspect_time_field = False
atomic_transactions = False
supports_combined_alters = False
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index fee6e59544..432658c21f 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from django.db import connection
-from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
+from django.test import TestCase, skipUnlessDBFeature
from .models import Reporter, Article
@@ -73,10 +73,9 @@ class IntrospectionTests(TestCase):
[30, 30, 75]
)
- # Oracle forces null=True under the hood in some cases (see
- # https://docs.djangoproject.com/en/dev/ref/databases/#null-and-empty-strings)
- # so its idea about null_ok in cursor.description is different from ours.
- @skipIfDBFeature('interprets_empty_strings_as_nulls')
+ # The following test fails on Oracle. Since it forces null=True under the
+ # hood in some cases, its idea about null_ok is different from ours.
+ @skipUnlessDBFeature('can_introspect_null')
def test_get_table_description_nullable(self):
with connection.cursor() as cursor:
desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table)