Skip to content

Commit cd70b44

Browse files
Some databases return a negative length instead of a 0 length when
returning null boolean values (#119).
1 parent 104ec03 commit cd70b44

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/oracledb/impl/thin/buffer.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,15 @@ cdef class Buffer:
368368

369369
cdef object read_bool(self):
370370
"""
371-
Read a boolean from the buffer and return True, False or None.
371+
Read a boolean from the buffer and return True, False or None. A zero
372+
length or a negative length (indicated by the value 0x81 in the first
373+
byte) implies a null value.
372374
"""
373375
cdef:
374376
const char_type *ptr
375377
ssize_t num_bytes
376378
self.read_raw_bytes_and_length(&ptr, &num_bytes)
377-
if ptr != NULL:
379+
if ptr != NULL and ptr[0] != 0x81:
378380
return ptr[num_bytes - 1] == 1
379381

380382
cdef object read_bytes(self):

0 commit comments

Comments
 (0)