Skip to content

Commit e65c07d

Browse files
committed
add missing SPB config parameters; fix DatabaseInfoProvider.implementation property; user new info codes in Statement
1 parent 37d92b1 commit e65c07d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/firebird/driver/core.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
StateResult, SrvDbInfoOption, ServerAction, CB_OUTPUT_LINE, FILESPEC,
7979
SrvBackupOption, SrvRestoreOption, SrvNBackupOption, SrvRepairOption,
8080
SrvPropertiesOption, SrvPropertiesFlag, SrvValidateOption,
81-
SrvUserOption, SrvTraceOption, UserInfo, TraceSession)
81+
SrvUserOption, SrvTraceOption, UserInfo, TraceSession, ReqInfoCode,
82+
StmtInfoCode)
8283
from .interfaces import iAttachment, iTransaction, iStatement, iMessageMetadata, iBlob, \
8384
iResultSet, iDtc, iService, iCryptKeyCallbackImpl
8485
from .hooks import APIHook, ConnectionHook, ServerHook, register_class, get_callbacks, add_hook
@@ -1409,7 +1410,7 @@ def firebird_version(self) -> str:
14091410
def implementation(self) -> Implementation:
14101411
"""Implementation (old format).
14111412
"""
1412-
return Implementation(self.get_info(DbInfoCode.IMPLEMENTATION_OLD)[0])
1413+
return Implementation(self.get_info(DbInfoCode.IMPLEMENTATION_OLD)[1])
14131414
@property
14141415
def provider(self) -> DbProvider:
14151416
"""Database Provider.
@@ -4035,10 +4036,10 @@ def affected_rows(self) -> int:
40354036
StatementType.UPDATE,
40364037
StatementType.DELETE)):
40374038
info = create_string_buffer(64)
4038-
self._stmt._istmt.get_info(bytes([23, 1]), info) # bytes(isc_info_sql_records, isc_info_end)
4039-
if ord(info[0]) != 23: # pragma: no cover
4039+
self._stmt._istmt.get_info(bytes([StmtInfoCode.RECORDS, isc_info_end]), info)
4040+
if ord(info[0]) != StmtInfoCode.RECORDS: # pragma: no cover
40404041
raise InterfaceError("Cursor.affected_rows:\n"
4041-
"first byte must be 'isc_info_sql_records'")
4042+
"first byte must be 'StmtInfoCode.RECORDS'")
40424043
res_walk = 3
40434044
while ord(info[res_walk]) != isc_info_end:
40444045
cur_count_type = ord(info[res_walk])
@@ -4047,10 +4048,10 @@ def affected_rows(self) -> int:
40474048
res_walk += 2
40484049
count = (0).from_bytes(info[res_walk:res_walk + size], 'little')
40494050
# pylint: disable=R0916
4050-
if ((cur_count_type == 13 and self._stmt.type == StatementType.SELECT)
4051-
or (cur_count_type == 14 and self._stmt.type == StatementType.INSERT)
4052-
or (cur_count_type == 15 and self._stmt.type == StatementType.UPDATE)
4053-
or (cur_count_type == 16 and self._stmt.type == StatementType.DELETE)):
4051+
if ((cur_count_type == ReqInfoCode.SELECT_COUNT and self._stmt.type == StatementType.SELECT)
4052+
or (cur_count_type == ReqInfoCode.INSERT_COUNT and self._stmt.type == StatementType.INSERT)
4053+
or (cur_count_type == ReqInfoCode.UPDATE_COUNT and self._stmt.type == StatementType.UPDATE)
4054+
or (cur_count_type == ReqInfoCode.DELETE_COUNT and self._stmt.type == StatementType.DELETE)):
40544055
result = count
40554056
res_walk += size
40564057
return result
@@ -5588,7 +5589,8 @@ def connect_server(server: str, *, user: str=None, password: str=None,
55885589
spb = SPB_ATTACH(user=user, password=password, config=srv_config.config.value,
55895590
trusted_auth=srv_config.trusted_auth.value,
55905591
auth_plugin_list=srv_config.auth_plugin_list.value,
5591-
expected_db=expected_db, role=role)
5592+
expected_db=expected_db, encoding=srv_config.encoding.value,
5593+
errors=srv_config.encoding_errors.value, role=role)
55925594
spb_buf = spb.get_buffer()
55935595
with a.get_api().master.get_dispatcher() as provider:
55945596
if crypt_callback is not None:

0 commit comments

Comments
 (0)