File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
package client
2
2
3
3
import (
4
+ "encoding/json"
4
5
"flag"
5
6
"fmt"
6
7
"strings"
@@ -82,6 +83,7 @@ func (s *clientTestSuite) testConn_CreateTable(c *C) {
82
83
e enum("test1", "test2"),
83
84
u tinyint unsigned,
84
85
i tinyint,
86
+ j json,
85
87
PRIMARY KEY (id)
86
88
) ENGINE=InnoDB DEFAULT CHARSET=utf8`
87
89
@@ -184,6 +186,14 @@ func (s *clientTestSuite) TestConn_Insert(c *C) {
184
186
c .Assert (pkg .AffectedRows , Equals , uint64 (1 ))
185
187
}
186
188
189
+ func (s * clientTestSuite ) TestConn_Insert2 (c * C ) {
190
+ str := `insert into mixer_test_conn (id, j) values(?, ?)`
191
+ j := json .RawMessage (`[]` )
192
+ pkg , err := s .c .Execute (str , []interface {}{2 , j }... )
193
+ c .Assert (err , IsNil )
194
+ c .Assert (pkg .AffectedRows , Equals , uint64 (1 ))
195
+ }
196
+
187
197
func (s * clientTestSuite ) TestConn_Select (c * C ) {
188
198
str := `select str, f, e from mixer_test_conn where id = 1`
189
199
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package client
2
2
3
3
import (
4
4
"encoding/binary"
5
+ "encoding/json"
5
6
"fmt"
6
7
"math"
7
8
@@ -127,6 +128,9 @@ func (s *Stmt) write(args ...interface{}) error {
127
128
case []byte :
128
129
paramTypes [i << 1 ] = MYSQL_TYPE_STRING
129
130
paramValues [i ] = append (PutLengthEncodedInt (uint64 (len (v ))), v ... )
131
+ case json.RawMessage :
132
+ paramTypes [i << 1 ] = MYSQL_TYPE_STRING
133
+ paramValues [i ] = append (PutLengthEncodedInt (uint64 (len (v ))), v ... )
130
134
default :
131
135
return fmt .Errorf ("invalid argument type %T" , args [i ])
132
136
}
You can’t perform that action at this time.
0 commit comments