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()) }) }