Skip to content

Commit cebde52

Browse files
Fixed bug when binding OUT a NULL boolean value (#119).
1 parent b07a524 commit cebde52

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

doc/src/release_notes.rst

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ oracledb 1.2.2 (TBD)
1313
Thin Mode Changes
1414
+++++++++++++++++
1515

16+
#) Fixed bug when binding OUT a NULL boolean value.
17+
(`issue 119 <https://github.com/oracle/python-oracledb/issues/119>`__).
18+
1619
Thick Mode Changes
1720
++++++++++++++++++
1821

src/oracledb/impl/thin/messages.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2023, 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
@@ -615,7 +615,9 @@ cdef class MessageWithData(Message):
615615
name=var_impl.dbtype.name)
616616
if not self.in_fetch:
617617
buf.read_sb4(&actual_num_bytes)
618-
if actual_num_bytes != 0 and column_value is not None:
618+
if actual_num_bytes < 0 and column_value is False:
619+
column_value = None
620+
elif actual_num_bytes != 0 and column_value is not None:
619621
unit_type = "bytes" if isinstance(column_value, bytes) \
620622
else "characters"
621623
errors._raise_err(errors.ERR_COLUMN_TRUNCATED,

tests/sql/create_schema.sql

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*-----------------------------------------------------------------------------
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023, 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
@@ -968,6 +968,9 @@ create or replace package &main_user..pkg_TestBooleans as
968968
a_Value udt_BooleanList
969969
) return number;
970970

971+
function TestOutValueNull
972+
return boolean;
973+
971974
procedure TestOutArrays (
972975
a_NumElements number,
973976
a_Value out nocopy udt_BooleanList
@@ -1011,6 +1014,12 @@ create or replace package body &main_user..pkg_TestBooleans as
10111014
return t_Result;
10121015
end;
10131016

1017+
function TestOutValueNull
1018+
return boolean is
1019+
begin
1020+
return null;
1021+
end;
1022+
10141023
procedure TestOutArrays (
10151024
a_NumElements number,
10161025
a_Value out nocopy udt_BooleanList

tests/test_3100_boolean_var.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2023, 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
@@ -89,5 +89,11 @@ def test_3107_bind_true(self):
8989
(True,))
9090
self.assertEqual(result, "TRUE")
9191

92+
def test_3108_bind_out_null(self):
93+
"3108 - test binding out a boolean value (None)"
94+
result = self.cursor.callfunc("pkg_TestBooleans.TestOutValueNull",
95+
bool)
96+
self.assertEqual(result, None)
97+
9298
if __name__ == "__main__":
9399
test_env.run_test_cases()

0 commit comments

Comments
 (0)