summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-09-26 08:43:50 +0200
committerClaude Paroz <claude@2xlibre.net>2014-09-26 20:03:44 +0200
commitdbdae3a75512bddbf0b75ea6354fb3fc4bdb53cf (patch)
tree0549f86a215a0a04703ed47ee8ec082d87f34cda /django/db
parent45840927d3516770be2654422e752357d5c063a5 (diff)
Fixed #22738 -- Abstracted boolean field type introspection
Thanks maxi for the report, Shai Berger for his help with the patch and Tim Graham for the review.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/backends/__init__.py4
-rw-r--r--django/db/backends/mysql/base.py2
-rw-r--r--django/db/backends/oracle/base.py28
3 files changed, 17 insertions, 17 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 9873d9cba6..8bdf6eed3c 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -614,8 +614,8 @@ class BaseDatabaseFeatures(object):
# Can the backend introspect an BinaryField, instead of an TextField?
can_introspect_binary_field = True
- # Can the backend introspect an BooleanField, instead of an IntegerField?
- can_introspect_boolean_field = True
+ # What is the type returned when the backend introspect a BooleanField?
+ introspected_boolean_field_type = 'BooleanField'
# Can the backend introspect an DecimalField, instead of an FloatField?
can_introspect_decimal_field = True
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 7223780081..0bd9c16e56 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -178,7 +178,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_regex_backreferencing = False
supports_date_lookup_using_string = False
can_introspect_binary_field = False
- can_introspect_boolean_field = False
+ introspected_boolean_field_type = 'IntegerField'
can_introspect_small_integer_field = True
supports_timezones = False
requires_explicit_null_ordering_when_grouping = True
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 083ba18daa..c9a59d3970 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -125,6 +125,20 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# select for update with limit can be achieved on Oracle, but not with the current backend.
supports_select_for_update_with_limit = False
+ @cached_property
+ def introspected_boolean_field_type(self):
+ """
+ Some versions of Oracle -- we've seen this on 11.2.0.1 and suspect
+ it goes back -- have a weird bug where, when an integer column is
+ defined with a default, its precision is later reported on introspection
+ as 0, regardless of the real precision. For Django introspection, this
+ means that such columns are reported as IntegerField even if they are
+ really BigIntegerField or BooleanField.
+
+ The bug is solved in Oracle 11.2.0.2 and up.
+ """
+ return 'IntegerField' if self.connection.oracle_full_version < '11.2.0.2' else 'BooleanField'
+
class DatabaseOperations(BaseDatabaseOperations):
compiler_module = "django.db.backends.oracle.compiler"
@@ -735,20 +749,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
except ValueError:
return None
- @cached_property
- def version_has_default_introspection_bug(self):
- """
- Some versions of Oracle -- we've seen this on 11.2.0.1 and suspect
- it goes back -- have a weird bug where, when an integer column is
- defined with a default, its precision is later reported on introspection
- as 0, regardless of the real precision. For Django introspection, this
- means that such columns are reported as IntegerField even if they are
- really BigIntegerField or BooleanField.
-
- The bug is solved in Oracle 11.2.0.2 and up.
- """
- return self.oracle_full_version < '11.2.0.2'
-
class OracleParam(object):
"""