summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-03-10 23:02:44 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2017-03-10 23:07:50 +0100
commit9924c8a8b0f4281ba018ca3292ed78718fabe362 (patch)
tree47f4e0b98adf028ae4c6e3ef7cf3501cdc880397
parente9e58ec65e949fb6cf46cdf90a24180e98cbd65a (diff)
[1.11.x] Fixed #27924 -- Added support for cx_Oracle 5.3.
- Fixed Oracle backend due to cx_Oracle 5.3 change in the Cursor.description behavior i.e. "Use None instead of 0 for items in the Cursor.description attribute that do not have any validity.". - Used cx_Oracle.Object.size() instead of len(). Thanks Tim Graham for the review. Backport of 75503a823f6358892fff5aeb3691683ad9cc5a60 from master
-rw-r--r--django/contrib/gis/db/backends/oracle/introspection.py4
-rw-r--r--django/db/backends/oracle/base.py3
-rw-r--r--django/db/backends/oracle/introspection.py8
-rw-r--r--docs/releases/1.11.txt2
4 files changed, 13 insertions, 4 deletions
diff --git a/django/contrib/gis/db/backends/oracle/introspection.py b/django/contrib/gis/db/backends/oracle/introspection.py
index 764ce7d243..555853731d 100644
--- a/django/contrib/gis/db/backends/oracle/introspection.py
+++ b/django/contrib/gis/db/backends/oracle/introspection.py
@@ -40,8 +40,8 @@ class OracleIntrospection(DatabaseIntrospection):
dim, srid = row
if srid != 4326:
field_params['srid'] = srid
- # Length of object array ( SDO_DIM_ARRAY ) is number of dimensions.
- dim = len(dim)
+ # Size of object array (SDO_DIM_ARRAY) is number of dimensions.
+ dim = dim.size()
if dim != 2:
field_params['dim'] = dim
finally:
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 8e23b95fed..be604455cf 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -550,7 +550,8 @@ def _rowfactory(row, cursor):
casted = []
for value, desc in zip(row, cursor.description):
if value is not None and desc[1] is Database.NUMBER:
- precision, scale = desc[4:6]
+ precision = desc[4] or 0
+ scale = desc[5] or 0
if scale == -127:
if precision == 0:
# NUMBER column: decimal-precision floating point
diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
index 2d04fdac56..10bcdefc2d 100644
--- a/django/db/backends/oracle/introspection.py
+++ b/django/db/backends/oracle/introspection.py
@@ -84,7 +84,13 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
name = force_text(desc[0]) # cx_Oracle always returns a 'str' on both Python 2 and 3
internal_size, default = field_map[name]
name = name % {} # cx_Oracle, for some reason, doubles percent signs.
- description.append(FieldInfo(*(name.lower(),) + desc[1:3] + (internal_size,) + desc[4:] + (default,)))
+ description.append(FieldInfo(*(
+ (name.lower(),) +
+ desc[1:3] +
+ (internal_size, desc[4] or 0, desc[5] or 0) +
+ desc[6:] +
+ (default,)
+ )))
return description
def table_name_converter(self, name):
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index 3ba4eb2e35..f20fb4bdd9 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -263,6 +263,8 @@ Database backends
<mysql-isolation-level>`. To avoid possible data loss, it's recommended to
switch from MySQL's default level, repeatable read, to read committed.
+* Added support for ``cx_Oracle`` 5.3.
+
Email
~~~~~