File tree 2 files changed +19
-0
lines changed
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) {
79
79
}
80
80
}
81
81
82
+ // RowNumber is returning the number of rows in the [Resultset].
83
+ //
84
+ // For a nil [Resultset] 0 is returned.
82
85
func (r * Resultset ) RowNumber () int {
83
86
if r == nil {
84
87
return 0
85
88
}
86
89
return len (r .Values )
87
90
}
88
91
92
+ // ColumnNumber is returning the number of fields in the [Resultset].
93
+ //
94
+ // For a nil [Resultset] 0 is returned.
89
95
func (r * Resultset ) ColumnNumber () int {
96
+ if r == nil {
97
+ return 0
98
+ }
90
99
return len (r .Fields )
91
100
}
92
101
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