Skip to content

Commit 3faf8d2

Browse files
Fixed bug with fetching years < 0 (#345).
1 parent 0953325 commit 3faf8d2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Thin Mode Changes
2525
``wait_timeout`` value and the connection request will not additionally be
2626
delayed by any internal network ping to the database (`issue 330
2727
<https://github.com/oracle/python-oracledb/issues/330>`__).
28+
#) Fixed bug in fetching dates with years less than 0
29+
(`issue 345 <https://github.com/oracle/python-oracledb/issues/345>`__).
30+
2831

2932
Thick Mode Changes
3033
++++++++++++++++++

src/oracledb/impl/base/buffer.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ cdef class Buffer:
341341
int8_t tz_hour = 0, tz_minute = 0
342342
uint32_t fsecond = 0
343343
int32_t seconds
344-
uint16_t year
344+
int16_t year
345345
year = (ptr[0] - 100) * 100 + ptr[1] - 100
346346
if num_bytes >= 11:
347347
fsecond = unpack_uint32(&ptr[7], BYTE_ORDER_MSB) // 1000

tests/test_1400_datetime_var.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ def test_1417(self):
297297
self.assertEqual(self.cursor.fetchone(), self.data_by_key[4])
298298
self.assertIsNone(self.cursor.fetchone())
299299

300+
def test_1418(self):
301+
"1418 - test fetching a date with year < 0"
302+
with self.assertRaises(ValueError):
303+
self.cursor.execute(
304+
"select to_date('-4712-01-01', 'SYYYY-MM-DD') from dual"
305+
)
306+
self.cursor.fetchone()
307+
300308

301309
if __name__ == "__main__":
302310
test_env.run_test_cases()

0 commit comments

Comments
 (0)