File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -79,14 +79,23 @@ func (r *Resultset) Reset(fieldsCount int) {
7979 }
8080}
8181
82+ // RowNumber is returning the number of rows in the [Resultset].
83+ //
84+ // For a nil [Resultset] 0 is returned.
8285func (r * Resultset ) RowNumber () int {
8386 if r == nil {
8487 return 0
8588 }
8689 return len (r .Values )
8790}
8891
92+ // ColumnNumber is returning the number of fields in the [Resultset].
93+ //
94+ // For a nil [Resultset] 0 is returned.
8995func (r * Resultset ) ColumnNumber () int {
96+ if r == nil {
97+ return 0
98+ }
9099 return len (r .Fields )
91100}
92101
Original file line number Diff line number Diff line change 1+ package mysql
2+
3+ import "testing"
4+
5+ func TestColumnNumber (t * testing.T ) {
6+ r := Result {}
7+ // Make sure ColumnNumber doesn't panic if ResultSet is nil
8+ // https://github.com/go-mysql-org/go-mysql/issues/964
9+ r .ColumnNumber ()
10+ }
You can’t perform that action at this time.
0 commit comments