File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,10 @@ func (r *Result) Close() {
34
34
r .Resultset = nil
35
35
}
36
36
}
37
+
38
+ func (r * Result ) HasResultset () bool {
39
+ if r .Resultset != nil && len (r .Resultset .Fields ) > 0 {
40
+ return true
41
+ }
42
+ return false
43
+ }
Original file line number Diff line number Diff line change
1
+ package mysql
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/require"
7
+ )
8
+
9
+ func TestHasResultset_false (t * testing.T ) {
10
+ r := NewResultReserveResultset (0 )
11
+ b := r .HasResultset ()
12
+ require .Equal (t , false , b )
13
+ }
14
+
15
+ func TestHasResultset_true (t * testing.T ) {
16
+ r := NewResultReserveResultset (1 )
17
+ b := r .HasResultset ()
18
+ require .Equal (t , true , b )
19
+ }
Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ func (c *Conn) WriteValue(value interface{}) error {
230
230
case nil :
231
231
return c .writeOK (nil )
232
232
case * Result :
233
- if v != nil && v .Resultset != nil {
233
+ if v != nil && v .HasResultset () {
234
234
return c .writeResultset (v .Resultset )
235
235
} else {
236
236
return c .writeOK (v )
You can’t perform that action at this time.
0 commit comments