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.
This commit is contained in:
Mariusz Felisiak 2017-03-10 23:02:44 +01:00 committed by GitHub
parent 29592eef19
commit 75503a823f
4 changed files with 13 additions and 4 deletions

View File

@ -36,8 +36,8 @@ class OracleIntrospection(DatabaseIntrospection):
dim, srid = row dim, srid = row
if srid != 4326: if srid != 4326:
field_params['srid'] = srid field_params['srid'] = srid
# Length of object array ( SDO_DIM_ARRAY ) is number of dimensions. # Size of object array (SDO_DIM_ARRAY) is number of dimensions.
dim = len(dim) dim = dim.size()
if dim != 2: if dim != 2:
field_params['dim'] = dim field_params['dim'] = dim
finally: finally:

View File

@ -530,7 +530,8 @@ def _rowfactory(row, cursor):
casted = [] casted = []
for value, desc in zip(row, cursor.description): for value, desc in zip(row, cursor.description):
if value is not None and desc[1] is Database.NUMBER: 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 scale == -127:
if precision == 0: if precision == 0:
# NUMBER column: decimal-precision floating point # NUMBER column: decimal-precision floating point

View File

@ -78,7 +78,13 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
name = force_text(desc[0]) # cx_Oracle always returns a 'str' name = force_text(desc[0]) # cx_Oracle always returns a 'str'
internal_size, default = field_map[name] internal_size, default = field_map[name]
name = name % {} # cx_Oracle, for some reason, doubles percent signs. 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 return description
def table_name_converter(self, name): def table_name_converter(self, name):

View File

@ -263,6 +263,8 @@ Database backends
<mysql-isolation-level>`. To avoid possible data loss, it's recommended to <mysql-isolation-level>`. To avoid possible data loss, it's recommended to
switch from MySQL's default level, repeatable read, to read committed. switch from MySQL's default level, repeatable read, to read committed.
* Added support for ``cx_Oracle`` 5.3.
Email Email
~~~~~ ~~~~~