Commit 2543217 1 parent 60bca03 commit 2543217 Copy full SHA for 2543217
File tree 5 files changed +36
-2
lines changed
5 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
5
5
and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
6
6
7
+ ## [ 1.10.9] - 2025-01-03
8
+
9
+ ### Fixed
10
+
11
+ - Fix #44 - Invalid affected_row count on multiple statements
12
+
7
13
## [ 1.10.8] - 2024-12-23
8
14
9
15
### Fixed
Original file line number Diff line number Diff line change 2
2
Changelog
3
3
#########
4
4
5
+ Version 1.10.9
6
+ ==============
7
+
8
+ - Fix #44 - Invalid affected_row count on multiple statements
9
+
5
10
Version 1.10.8
6
11
==============
7
12
Original file line number Diff line number Diff line change 61
61
Server , Statement )
62
62
63
63
#: Current driver version, SEMVER string.
64
- __VERSION__ = '1.10.8 '
64
+ __VERSION__ = '1.10.9 '
Original file line number Diff line number Diff line change @@ -4134,7 +4134,19 @@ def affected_rows(self) -> int:
4134
4134
"""
4135
4135
if self ._stmt is None :
4136
4136
return - 1
4137
- return sum (self ._stmt .info .get_info (StmtInfoCode .RECORDS ).values ())
4137
+ rows : Dict [ReqInfoCode , int ] = self ._stmt .info .get_info (StmtInfoCode .RECORDS )
4138
+ code : ReqInfoCode = None
4139
+ if self ._stmt .type in (StatementType .SELECT , StatementType .SELECT_FOR_UPD ):
4140
+ code = ReqInfoCode .SELECT_COUNT
4141
+ elif self ._stmt .type == StatementType .UPDATE :
4142
+ code = ReqInfoCode .UPDATE_COUNT
4143
+ elif self ._stmt .type == StatementType .INSERT :
4144
+ code = ReqInfoCode .INSERT_COUNT
4145
+ elif self ._stmt .type == StatementType .DELETE :
4146
+ code = ReqInfoCode .DELETE_COUNT
4147
+ else :
4148
+ return - 1
4149
+ return rows [code ]
4138
4150
rowcount = affected_rows
4139
4151
@property
4140
4152
def transaction (self ) -> TransactionManager :
Original file line number Diff line number Diff line change @@ -1043,6 +1043,17 @@ def test_affected_rows(self):
1043
1043
rcount = 1
1044
1044
self .assertEqual (cur .affected_rows , rcount )
1045
1045
self .assertEqual (cur .rowcount , rcount )
1046
+ def test_affected_rows_with_multiple_execute_statements_and_different_command (self ):
1047
+ with self .con .cursor () as cur :
1048
+ cur .execute ("insert into project (proj_id, proj_name) values ('FOO', 'BAR')" )
1049
+ cur .execute ("update project set proj_name = 'RAB' where proj_id = 'FOO'" )
1050
+ cur .fetchone ()
1051
+ if sys .platform == 'win32' :
1052
+ rcount = 6
1053
+ else :
1054
+ rcount = 1
1055
+ self .assertEqual (cur .affected_rows , rcount )
1056
+ self .assertEqual (cur .rowcount , rcount )
1046
1057
def test_name (self ):
1047
1058
def assign_name ():
1048
1059
cur .set_cursor_name ('testx' )
You can’t perform that action at this time.
0 commit comments