Fixed #27788 -- Dropped support for Oracle < 12.1.

This commit is contained in:
Tim Graham 2017-01-28 08:19:47 -05:00 committed by GitHub
parent a6755b29e9
commit 0de0699d94
9 changed files with 23 additions and 42 deletions

View File

@ -17,7 +17,6 @@ from django.contrib.gis.db.models import aggregates
from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance from django.contrib.gis.measure import Distance
from django.db.backends.oracle.operations import DatabaseOperations from django.db.backends.oracle.operations import DatabaseOperations
from django.utils.functional import cached_property
DEFAULT_TOLERANCE = '0.05' DEFAULT_TOLERANCE = '0.05'
@ -132,15 +131,10 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
truncate_params = {'relate': None} truncate_params = {'relate': None}
@cached_property unsupported_functions = {
def unsupported_functions(self):
unsupported = {
'AsGeoJSON', 'AsKML', 'AsSVG', 'Envelope', 'ForceRHR', 'GeoHash', 'AsGeoJSON', 'AsKML', 'AsSVG', 'Envelope', 'ForceRHR', 'GeoHash',
'MakeValid', 'MemSize', 'Scale', 'SnapToGrid', 'Translate', 'MakeValid', 'MemSize', 'Scale', 'SnapToGrid', 'Translate',
} }
if self.connection.oracle_full_version < '12.1.0.2':
unsupported.add('BoundingCircle')
return unsupported
def geo_quote_name(self, name): def geo_quote_name(self, name):
return super().geo_quote_name(name).upper() return super().geo_quote_name(name).upper()

View File

@ -253,18 +253,15 @@ class BaseDatabaseFeatures:
except NotImplementedError: except NotImplementedError:
return False return False
def introspected_boolean_field_type(self, field=None, created_separately=False): def introspected_boolean_field_type(self, field=None):
""" """
What is the type returned when the backend introspects a BooleanField? What is the type returned when the backend introspects a BooleanField?
The optional arguments may be used to give further details of the field to be The `field` argument may be used to give further details of the field
introspected; in particular, they are provided by Django's test suite: to be introspected.
field -- the field definition
created_separately -- True if the field was added via a SchemaEditor's AddField,
False if the field was created with the model
Note that return value from this function is compared by tests against actual The return value from this function is compared by tests against actual
introspection results; it should provide expectations, not run an introspection introspection results; it should provide expectations, not run an
itself. introspection itself.
""" """
if self.can_introspect_null and field and field.null: if self.can_introspect_null and field and field.null:
return 'NullBooleanField' return 'NullBooleanField'

View File

@ -35,18 +35,3 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# Oracle doesn't ignore quoted identifiers case but the current backend # Oracle doesn't ignore quoted identifiers case but the current backend
# does by uppercasing all identifiers. # does by uppercasing all identifiers.
ignores_table_name_case = True ignores_table_name_case = True
def introspected_boolean_field_type(self, field=None, created_separately=False):
"""
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
added to an existing table 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.
"""
if self.connection.oracle_full_version < '11.2.0.2' and field and field.has_default() and created_separately:
return 'IntegerField'
return super().introspected_boolean_field_type(field, created_separately)

View File

@ -376,7 +376,7 @@ Function PostGIS Oracle MySQL Spat
:class:`AsGML` X X X :class:`AsGML` X X X
:class:`AsKML` X X :class:`AsKML` X X
:class:`AsSVG` X X :class:`AsSVG` X X
:class:`BoundingCircle` X X (≥ 12.1.0.2) :class:`BoundingCircle` X X
:class:`Centroid` X X X X :class:`Centroid` X X X X
:class:`Difference` X X X (≥ 5.6.1) X :class:`Difference` X X X (≥ 5.6.1) X
:class:`Distance` X X X (≥ 5.6.1) X :class:`Distance` X X X (≥ 5.6.1) X

View File

@ -170,7 +170,7 @@ __ http://www.w3.org/Graphics/SVG/
.. class:: BoundingCircle(expression, num_seg=48, **extra) .. class:: BoundingCircle(expression, num_seg=48, **extra)
*Availability*: `PostGIS <http://postgis.net/docs/ST_MinimumBoundingCircle.html>`__, *Availability*: `PostGIS <http://postgis.net/docs/ST_MinimumBoundingCircle.html>`__,
`Oracle (≥ 12.1.0.2) <https://docs.oracle.com/database/121/SPATL/GUID-82A61626-BB64-4793-B53D-A0DBEC91831A.htm#SPATL1554>`_ `Oracle <https://docs.oracle.com/database/121/SPATL/GUID-82A61626-BB64-4793-B53D-A0DBEC91831A.htm#SPATL1554>`_
Accepts a single geographic field or expression and returns the smallest circle Accepts a single geographic field or expression and returns the smallest circle
polygon that can fully contain the geometry. polygon that can fully contain the geometry.

View File

@ -676,7 +676,7 @@ rather than a list. SQLite does not support this.
Oracle notes Oracle notes
============ ============
Django supports `Oracle Database Server`_ versions 11.2 and higher. Version Django supports `Oracle Database Server`_ versions 12.1 and higher. Version
5.2 or higher of the `cx_Oracle`_ Python driver is required. 5.2 or higher of the `cx_Oracle`_ Python driver is required.
.. _`Oracle Database Server`: http://www.oracle.com/ .. _`Oracle Database Server`: http://www.oracle.com/

View File

@ -210,6 +210,13 @@ Database backend API
* ... * ...
Dropped support for Oracle 11.2
-------------------------------
The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be
supported until April 2020 which almost reaches this date. Django 2.0
officially supports Oracle 12.1+.
Miscellaneous Miscellaneous
------------- -------------

View File

@ -305,10 +305,8 @@ class GISFunctionsTests(TestCase):
for c in mpoly_qs: for c in mpoly_qs:
self.assertEqual(c.mpoly.num_points, c.num_points) self.assertEqual(c.mpoly.num_points, c.num_points)
if not oracle:
# Oracle cannot count vertices in Point geometries.
for c in City.objects.annotate(num_points=functions.NumPoints('point')): for c in City.objects.annotate(num_points=functions.NumPoints('point')):
self.assertEqual(1, c.num_points) self.assertEqual(c.num_points, 1)
@skipUnlessDBFeature("has_PointOnSurface_function") @skipUnlessDBFeature("has_PointOnSurface_function")
def test_point_on_surface(self): def test_point_on_surface(self):

View File

@ -416,7 +416,7 @@ class SchemaTests(TransactionTestCase):
field_type = columns['awesome'][0] field_type = columns['awesome'][0]
self.assertEqual( self.assertEqual(
field_type, field_type,
connection.features.introspected_boolean_field_type(new_field, created_separately=True) connection.features.introspected_boolean_field_type(new_field)
) )
def test_add_field_default_transform(self): def test_add_field_default_transform(self):