diff --git a/README.rst b/README.rst index c72e0e3..2132b34 100644 --- a/README.rst +++ b/README.rst @@ -163,6 +163,7 @@ Changelog - Return (big) decimal types as long value if scale is zero (thanks to @ministat) + - Fix `DECIMAL` and `NUMERIC` type conversion for Jython - 1.2.1 - 2020-05-27 diff --git a/jaydebeapi/__init__.py b/jaydebeapi/__init__.py index 484a1d1..b66c444 100644 --- a/jaydebeapi/__init__.py +++ b/jaydebeapi/__init__.py @@ -663,19 +663,19 @@ def _java_to_py(java_method): return getattr(java_val, java_method)() return to_py -def _java_to_py_bigdecimal(java_method): +def _java_to_py_bigdecimal(): def to_py(rs, col): java_val = rs.getObject(col) if java_val is None: return if hasattr(java_val, 'scale'): - scale = getattr(java_val, 'scale')() + scale = java_val.scale() if scale == 0: - return getattr(java_val, 'longValue')() + return java_val.longValue() else: - return getattr(java_val, java_method)() + return java_val.doubleValue() else: - return getattr(java_val, java_method)() + return float(java_val) return to_py _to_double = _java_to_py('doubleValue') @@ -684,7 +684,7 @@ _to_int = _java_to_py('intValue') _to_boolean = _java_to_py('booleanValue') -_to_decimal = _java_to_py_bigdecimal('doubleValue') +_to_decimal = _java_to_py_bigdecimal() def _init_types(types_map): global _jdbc_name_to_const