Skip to content

Commit 5fd1065

Browse files
Fix conversion from BINARY_DOUBLE/BINARY_FLOAT to string.
1 parent cb29895 commit 5fd1065

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/oracledb/impl/base/converters.pyx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 2025, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -180,6 +180,14 @@ cdef object convert_oracle_data_to_python(OracleMetadata from_metadata,
180180
elif ora_type_num == ORA_TYPE_NUM_NUMBER:
181181
return convert_number_to_python_str(&data.buffer)
182182

183+
# Oracle BINARY_DOUBLE
184+
elif ora_type_num == ORA_TYPE_NUM_BINARY_DOUBLE:
185+
return str(data.buffer.as_double)
186+
187+
# Oracle BINARY_FLOAT
188+
elif ora_type_num == ORA_TYPE_NUM_BINARY_FLOAT:
189+
return str(data.buffer.as_float)
190+
183191
# Oracle DATE, TIMESTAMP (WITH (LOCAL) TIME ZONE)
184192
elif ora_type_num in (
185193
ORA_TYPE_NUM_DATE,

tests/test_3600_outputtypehandler.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,26 @@ def type_handler_2(cursor, metadata):
707707
self.cursor.execute(sql, [0])
708708
self.assertEqual(self.cursor.fetchall(), [])
709709

710+
def test_3677(self):
711+
"3677 - output type handler: from BINARY_DOUBLE to VARCHAR"
712+
str_value = "36.75" if test_env.get_is_thin() else "3.675E+001"
713+
self.__test_type_handler(
714+
oracledb.DB_TYPE_BINARY_DOUBLE,
715+
oracledb.DB_TYPE_VARCHAR,
716+
36.75,
717+
str_value,
718+
)
719+
720+
def test_3678(self):
721+
"3678 - output type handler: from BINARY_FLOAT to VARCHAR"
722+
str_value = "16.25" if test_env.get_is_thin() else "1.625E+001"
723+
self.__test_type_handler(
724+
oracledb.DB_TYPE_BINARY_FLOAT,
725+
oracledb.DB_TYPE_VARCHAR,
726+
16.25,
727+
str_value,
728+
)
729+
710730

711731
if __name__ == "__main__":
712732
test_env.run_test_cases()

0 commit comments

Comments
 (0)