Skip to content

Commit 4ca0c80

Browse files
Fixed regression which prevented a null value from being set on DbObject
attributes or used as elements of collections (#273).
1 parent c1c4ef8 commit 4ca0c80

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Thin Mode Changes
1919
Common Changes
2020
++++++++++++++
2121

22+
#) Fixed regression which prevented a null value from being set on DbObject
23+
attributes or used as elements of collections
24+
(`issue 273 <https://github.com/oracle/python-oracledb/issues/273>`__).
2225
#) Corrected typing declarations.
2326

2427

src/oracledb/impl/base/dbobject.pyx

Lines changed: 2 additions & 2 deletions
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, 2024, 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
@@ -37,7 +37,7 @@ cdef class BaseDbObjectImpl:
3737
Checks to see if the maximum size has been violated.
3838
"""
3939
violated[0] = False
40-
if max_size > 0:
40+
if max_size > 0 and value is not None:
4141
if isinstance(value, str):
4242
actual_size[0] = len((<str> value).encode())
4343
else:

tests/test_2300_object_var.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2024, 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
@@ -771,6 +771,12 @@ def test_2334_validate_string_element_value(self):
771771
"C" * 101,
772772
)
773773

774+
def test_2335_validate_string_attr_null(self):
775+
"2335 - test validating a string attribute with null value"
776+
typ = self.conn.gettype("UDT_OBJECT")
777+
obj = typ.newobject()
778+
obj.STRINGVALUE = None
779+
774780

775781
if __name__ == "__main__":
776782
test_env.run_test_cases()

0 commit comments

Comments
 (0)