Skip to content

Commit f32fe0a

Browse files
committed
Fix for TIMEZONE and INT128 ARRAYs
1 parent b46728c commit f32fe0a

File tree

10 files changed

+1072
-7
lines changed

10 files changed

+1072
-7
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [1.10.6] - 2024-08-15
8+
9+
### Fixed
10+
11+
- Unregistered bug: Big NUMERIC/DECIMAL (i.e. INT128) ARRAYs do not work.
12+
- Unregistered bug: ARRAYs of TIME WITH TIMEZONE do not work.
13+
714
## [1.10.5] - 2024-07-26
815

916
### Fixed

docs/changelog.txt

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
#########
44

5+
Version 1.10.6
6+
==============
7+
8+
- Fix: Big NUMERIC/DECIMAL (i.e. INT128) ARRAYs do not work.
9+
- Fix: ARRAYs of TIME WITH TIMEZONE do not work.
10+
511
Version 1.10.5
612
==============
713

src/firebird/driver/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161
Server, Statement)
6262

6363
#: Current driver version, SEMVER string.
64-
__VERSION__ = '1.10.5'
64+
__VERSION__ = '1.10.6'

src/firebird/driver/core.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
_util = None
132132
_thns = threading.local()
133133

134-
_tenTo = [10 ** x for x in range(20)]
134+
_tenTo = [10 ** x for x in range(30)]
135135
_i2name = {DbInfoCode.READ_SEQ_COUNT: 'sequential', DbInfoCode.READ_IDX_COUNT: 'indexed',
136136
DbInfoCode.INSERT_COUNT: 'inserts', DbInfoCode.UPDATE_COUNT: 'updates',
137137
DbInfoCode.DELETE_COUNT: 'deletes', DbInfoCode.BACKOUT_COUNT: 'backouts',
@@ -3078,7 +3078,7 @@ def _extract_db_array_to_list(self, esize: int, dtype: int, subtype: int,
30783078
elif dtype in (a.blr_short, a.blr_long, a.blr_int64):
30793079
val = (0).from_bytes(buf[bufpos:bufpos + esize], 'little', signed=True)
30803080
if subtype or scale:
3081-
val = decimal.Decimal(val) / _tenTo[abs(256-scale)]
3081+
val = decimal.Decimal(val) / _tenTo[abs(scale)]
30823082
elif dtype == a.blr_bool:
30833083
val = (0).from_bytes(buf[bufpos:bufpos + esize], 'little') == 1
30843084
elif dtype == a.blr_float:
@@ -3173,9 +3173,9 @@ def _fill_db_array_buffer(self, esize: int, dtype: int, subtype: int,
31733173
if subtype or scale:
31743174
val = value[i]
31753175
if isinstance(val, decimal.Decimal):
3176-
val = int((val * _tenTo[256-abs(scale)]).to_integral())
3176+
val = int((val * _tenTo[abs(scale)]).to_integral())
31773177
elif isinstance(val, (int, float)):
3178-
val = int(val * _tenTo[256-abs(scale)])
3178+
val = int(val * _tenTo[abs(scale)])
31793179
else:
31803180
raise TypeError(f'Objects of type {type(val)} are not '
31813181
f' acceptable input for'
@@ -3214,7 +3214,7 @@ def _fill_db_array_buffer(self, esize: int, dtype: int, subtype: int,
32143214
valuebuf.value = _util.encode_time(value[i]).to_bytes(4, 'little')
32153215
memmove(byref(buf, bufpos), valuebuf, esize)
32163216
elif dtype == a.blr_sql_time_tz:
3217-
valuebuf.value = _util.encode_time_tz(value[i]).to_bytes(esize, 'little')
3217+
valuebuf.value = _util.encode_time_tz(value[i])
32183218
memmove(byref(buf, bufpos), valuebuf, esize)
32193219
elif dtype == a.blr_timestamp_tz:
32203220
valuebuf.value = _util.encode_timestamp_tz(value[i])

src/firebird/driver/fbapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class ISC_ARRAY_DESC(Structure):
294294
"ISC_ARRAY_DESC"
295295
_fields_ = [
296296
('array_desc_dtype', c_ubyte),
297-
('array_desc_scale', c_ubyte), # was ISC_SCHAR),
297+
('array_desc_scale', c_byte), # was ISC_SCHAR),
298298
('array_desc_length', c_ushort),
299299
('array_desc_field_name', c_char * 32),
300300
('array_desc_relation_name', c_char * 32),

src/firebird/driver/types.py

+3
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,9 @@ def get_timezone(timezone: str=None) -> datetime.tzinfo:
14171417
for timezone tzinfo objects, but adds metadata neccessary to store timezone regions into
14181418
database instead zoned time, and to handle offset-based timezones in format required by
14191419
Firebird.
1420+
1421+
Arguments:
1422+
timezone: Timezone region specification or UTC offset.
14201423
"""
14211424
if timezone[0] in ('+', '-'):
14221425
timezone = 'UTC' + timezone

tests/fbtest40.fdb

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)