From 7c25152d7a40534d4928d446070d274d19c69202 Mon Sep 17 00:00:00 2001 From: Matvey Gubanikhin Date: Thu, 5 Nov 2026 15:36:05 +0300 Subject: [PATCH] Fix calculation of number of affected rows. --- fbconn/statement.go | 6 +++++- rows_test.go | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fbconn/statement.go b/fbconn/statement.go index 5dbc7db..643421a 100644 --- a/fbconn/statement.go +++ b/fbconn/statement.go @@ -78,7 +78,11 @@ func (sd *StatementDescription) HaveSingletonResult() bool { } func (sd *StatementDescription) GetAffectedCount() int64 { - return sd.StatementInfo.Counts.SelectCount + sd.StatementInfo.Counts.InsertCount + sd.StatementInfo.Counts.UpdateCount + sd.StatementInfo.Counts.DeleteCount + modifiedCount := sd.StatementInfo.Counts.InsertCount + sd.StatementInfo.Counts.UpdateCount + sd.StatementInfo.Counts.DeleteCount + if modifiedCount != 0 { + return modifiedCount + } + return sd.StatementInfo.Counts.SelectCount } func (sd *StatementDescription) EncodeBatchRow(values [][]byte) ([]byte, error) { diff --git a/rows_test.go b/rows_test.go index 9a46630..75e8f4e 100644 --- a/rows_test.go +++ b/rows_test.go @@ -104,9 +104,7 @@ begin end`, "rows_counts_test", "rows_counts_test", "rows_counts_test")) require.NoError(t, err) - // Firebird reports counts for all operations inside the block (including internal reads), - // so the aggregated RowsAffected should reflect the sum returned by isc_info_sql_records. - require.EqualValues(t, 5, ct.RowsAffected()) + require.EqualValues(t, 3, ct.RowsAffected()) }) }