Skip to content

Commit a6d99ca

Browse files
Fixed bug when fetching dates that are in the year 2038 or later.
1 parent f402975 commit a6d99ca

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Common Changes
6262
(`issue 510 <https://github.com/oracle/python-oracledb/issues/510>`__)
6363
- Fixed bug when fetching numeric data that has no decimal point but the
6464
Arrow array has scale > 0
65+
- Fixed bug when fetching dates that are in the year 2038 or later
6566

6667
Note the data frame support in python-oracledb 3.3 is a pre-release, and
6768
may change in a future version.

src/oracledb/impl/base/converters.pyx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ cdef object convert_arrow_to_oracle_data(OracleMetadata metadata,
3737
Converts the value stored in Arrow format to an OracleData structure.
3838
"""
3939
cdef:
40+
int64_t int64_value, days, seconds, useconds
4041
SparseVectorImpl sparse_impl
41-
int seconds, useconds
4242
ArrowType arrow_type
43-
int64_t int64_value
4443
OracleRawBytes* rb
4544
tuple sparse_info
4645
bytes temp_bytes
@@ -75,11 +74,14 @@ cdef object convert_arrow_to_oracle_data(OracleMetadata metadata,
7574
if not data.is_null:
7675
seconds = int64_value // arrow_array.time_factor
7776
useconds = int64_value % arrow_array.time_factor
77+
days = seconds // (24 * 60 * 60)
78+
seconds = seconds % (24 * 60 * 60)
7879
if arrow_array.time_factor == 1_000:
7980
useconds *= 1_000
8081
elif arrow_array.time_factor == 1_000_000_000:
8182
useconds //= 1_000
82-
return EPOCH_DATE + cydatetime.timedelta_new(0, seconds, useconds)
83+
return EPOCH_DATE + \
84+
cydatetime.timedelta_new(days, seconds, useconds)
8385
elif arrow_type == NANOARROW_TYPE_DECIMAL128:
8486
temp_bytes = arrow_array.get_decimal(array_index, &data.is_null)
8587
if not data.is_null:

0 commit comments

Comments
 (0)